SlideShare a Scribd company logo
1 of 45
快快樂樂成為 Coding Ninja
(by pytest)
Chun-Yu Tseng
快快樂樂成為 Coding Ninja
(by pytest)
Joe a.k.a. 魯蛇喬
寫 API ..
寫出更多 API ..
寫出更多 API .. 以及 bugs
半年後開始撰寫測試(沒有
用 testing tool)
寫 Web (few tests)
寫 API (try ATDD)
已經開始用 pytest (level 0)
我放假半年 XD
寫寫 API 賺零用錢、辦
Tainan.py 聚會、吃雞排看
TDD 大戰、看看 Agile、設計
心理學、被 Haskell 電爆 … 認
真學習 pytest 怎麼用
加入一個傳說中有很多
python code 的非營利組織
結果其實天殺的 js 更多
寫一點 e2e tests
徵人
專業測試很難
開發者仍需有基本的測試思維
學習基本概念的門檻略高(都是 xUnit Style)
讓新手快快樂樂上手 pytest 及接觸測試思維
讓進階者 …
呃 … 天涼就加件外套吧!
為什麼你不寫測試?
pytest 是啥?
快快樂樂上手貼司挺
邁向 Coding Ninja 之路!
為什麼你不寫測試?
pytest 是啥?
快快樂樂上手貼司挺
邁向 Coding Ninja 之路!
幹嘛要測試軟體?
你選擇用哪種方式來測試?
自己來
讓同事測(交情大考驗)
讓老闆/PM測(薪水大考驗)
讓使用者測(人品大考驗之時間不夠的密技)
在開發環境跑 unit testing
在 CI server 跑 integration/functional testing
為什麼你不寫測試?
理由一:不需要測
理由二:不好測
理由三:不會寫
理由四:懶得寫
理由一:不需要測
理由二:不好測
理由三:不會寫
理由四:懶得寫
立馬來解決這兩個問題!
不會寫
這是很實際的測試方式
但是不實用 …
所以我們會使用 testing framework 來協助我們測
試(撰寫上要遵守特定的規則)
太隨性的問題
從此以後可以開心的寫測試?
從此以後可以開心的寫測試?
才怪
要寫好多 Code
莫名的 assertEqual API …
滿滿的 Old xUnit Style …
setUp / tearDown
讓我們來解決懶得寫的問題!
為什麼你不寫測試?
pytest 是啥?
快快樂樂上手貼司挺
邁向 Coding Ninja 之路!
另一個 testing framework
採用更加 Pythonic 的方式來協助測試
並且向下支援 xUnit Style 的測試程式碼
玩玩看就知道了!
懶得寫
No-boilerplate testing (不用再繼承 …)
Assert 打天下
偏好用扁平化的方式組織測試程式碼
推
可以用 yield 的方式製造出 fixture
再也不用擔心 db.close(), f.close() 的問題
可以自訂 fixture 的生存 scope
function/class/file/module/session
支援用 fixture 生成 fixture
Test discovery
Mark system (分群組、skipif …)
Parametrized test functions
Plugins
趕快到 官網 瞧瞧!
為什麼你不寫測試?
pytest 是啥?
快快樂樂上手貼司挺
邁向 Coding Ninja 之路!
寫個 unit test 先
再寫個 integration test
KO 掉 functional test
為什麼你不寫測試?
pytest 是啥?
快快樂樂上手貼司挺
邁向 Coding Ninja 之路!
告訴你測試的好處
解決不會寫、懶得寫的問題
簡介 pytest
寫了三種類型的入門測試
更加熟悉 testing tool (pytest/nose/unittest ..)
更深入地探討三種測試
了解 (OO) Design 相關的原則與 patterns
嘗試看看 TDD/*DD
Coding Ninja
最終目的仍然是「開發」
不要過度測試
自己去判斷該不該測
加快 feedback loop 與保持
confidence 是秘訣
成為 Coding Ninja 的不二法門
Done
工商服務(上)
均一教育平台招募:實習生、正職員工
http://junyiacademyhr.weebly.com/
工商服務(下)
Tainan.py 六月份聚會暫定於 6/27 於台南舉辦
https://www.facebook.com/groups/mosut
assert QA.time == False
Thank
You

More Related Content

Viewers also liked

Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522Fei Ji Siao
 
Machine learning in finance using python
Machine learning in finance using pythonMachine learning in finance using python
Machine learning in finance using pythonEric Tham
 
Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)
Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)
Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)Takayuki Shimizukawa
 
Mozilla Web QA: Who, What, Why, How
Mozilla Web QA: Who, What, Why, HowMozilla Web QA: Who, What, Why, How
Mozilla Web QA: Who, What, Why, HowStephen Donner
 
Testing for people who hate testing
Testing for people who hate testingTesting for people who hate testing
Testing for people who hate testingSam Bolgert
 
Mozilla Web QA - Evolution of our Python WebDriver framework
Mozilla Web QA - Evolution of our Python WebDriver frameworkMozilla Web QA - Evolution of our Python WebDriver framework
Mozilla Web QA - Evolution of our Python WebDriver frameworkdavehunt82
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksLohika_Odessa_TechTalks
 
Easy selenium test automation on python
Easy selenium test automation on pythonEasy selenium test automation on python
Easy selenium test automation on pythonMykhailo Poliarush
 
Building a Graph of all US Businesses Using Spark Technologies by Alexis Roos
Building a Graph of all US Businesses Using Spark Technologies by Alexis RoosBuilding a Graph of all US Businesses Using Spark Technologies by Alexis Roos
Building a Graph of all US Businesses Using Spark Technologies by Alexis RoosSpark Summit
 
Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...
Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...
Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...Spark Summit
 
Test Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.comTest Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.comIdexcel Technologies
 
Agile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated TestingAgile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated TestingDimitri Ponomareff
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planningSivaprasanthRentala1975
 

Viewers also liked (13)

Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522Onos sdn ip 建置之路 20160522
Onos sdn ip 建置之路 20160522
 
Machine learning in finance using python
Machine learning in finance using pythonMachine learning in finance using python
Machine learning in finance using python
 
Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)
Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)
Sphinx autodoc - automated API documentation (PyCon APAC 2015 in Taiwan)
 
Mozilla Web QA: Who, What, Why, How
Mozilla Web QA: Who, What, Why, HowMozilla Web QA: Who, What, Why, How
Mozilla Web QA: Who, What, Why, How
 
Testing for people who hate testing
Testing for people who hate testingTesting for people who hate testing
Testing for people who hate testing
 
Mozilla Web QA - Evolution of our Python WebDriver framework
Mozilla Web QA - Evolution of our Python WebDriver frameworkMozilla Web QA - Evolution of our Python WebDriver framework
Mozilla Web QA - Evolution of our Python WebDriver framework
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
 
Easy selenium test automation on python
Easy selenium test automation on pythonEasy selenium test automation on python
Easy selenium test automation on python
 
Building a Graph of all US Businesses Using Spark Technologies by Alexis Roos
Building a Graph of all US Businesses Using Spark Technologies by Alexis RoosBuilding a Graph of all US Businesses Using Spark Technologies by Alexis Roos
Building a Graph of all US Businesses Using Spark Technologies by Alexis Roos
 
Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...
Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...
Relationship Extraction from Unstructured Text-Based on Stanford NLP with Spa...
 
Test Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.comTest Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.com
 
Agile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated TestingAgile Testing Framework - The Art of Automated Testing
Agile Testing Framework - The Art of Automated Testing
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planning
 

Similar to 快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015

Testing in Python @ Kaosiung.py 2014.05.26
Testing in Python @ Kaosiung.py 2014.05.26Testing in Python @ Kaosiung.py 2014.05.26
Testing in Python @ Kaosiung.py 2014.05.26Chun-Yu Tseng
 
简单Pthon教程
简单Pthon教程简单Pthon教程
简单Pthon教程junjun chen
 
Python简明教程
Python简明教程Python简明教程
Python简明教程ingong
 
探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan
探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan
探索 API 開發的挑戰與解決之道 | .NET Conf 2023 TaiwanAlan Tsai
 
EOS_2015_Fall Team6 - One to Ten App Design Toolkit
EOS_2015_Fall  Team6 - One to Ten App Design ToolkitEOS_2015_Fall  Team6 - One to Ten App Design Toolkit
EOS_2015_Fall Team6 - One to Ten App Design Toolkitnctusee
 
Python 入門初體驗
Python 入門初體驗Python 入門初體驗
Python 入門初體驗政斌 楊
 
2 Python开发工具链
2 Python开发工具链2 Python开发工具链
2 Python开发工具链March Liu
 
from passion import profession
from passion import professionfrom passion import profession
from passion import professionTsungWei Hu
 
Rails 炸機實務
Rails  炸機實務Rails  炸機實務
Rails 炸機實務Manic
 
TeamToy-创新团队的效率工具
TeamToy-创新团队的效率工具TeamToy-创新团队的效率工具
TeamToy-创新团队的效率工具easychen
 

Similar to 快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015 (14)

Testing in Python @ Kaosiung.py 2014.05.26
Testing in Python @ Kaosiung.py 2014.05.26Testing in Python @ Kaosiung.py 2014.05.26
Testing in Python @ Kaosiung.py 2014.05.26
 
简单Pthon教程
简单Pthon教程简单Pthon教程
简单Pthon教程
 
Python简明教程
Python简明教程Python简明教程
Python简明教程
 
探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan
探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan
探索 API 開發的挑戰與解決之道 | .NET Conf 2023 Taiwan
 
EOS_2015_Fall Team6 - One to Ten App Design Toolkit
EOS_2015_Fall  Team6 - One to Ten App Design ToolkitEOS_2015_Fall  Team6 - One to Ten App Design Toolkit
EOS_2015_Fall Team6 - One to Ten App Design Toolkit
 
Python 入門初體驗
Python 入門初體驗Python 入門初體驗
Python 入門初體驗
 
2 Python开发工具链
2 Python开发工具链2 Python开发工具链
2 Python开发工具链
 
from passion import profession
from passion import professionfrom passion import profession
from passion import profession
 
getPDF.aspx
getPDF.aspxgetPDF.aspx
getPDF.aspx
 
getPDF.aspx
getPDF.aspxgetPDF.aspx
getPDF.aspx
 
Rails 炸機實務
Rails  炸機實務Rails  炸機實務
Rails 炸機實務
 
Python系列1
Python系列1Python系列1
Python系列1
 
Python系列4
Python系列4Python系列4
Python系列4
 
TeamToy-创新团队的效率工具
TeamToy-创新团队的效率工具TeamToy-创新团队的效率工具
TeamToy-创新团队的效率工具
 

More from Chun-Yu Tseng

驚呆了!這些 Python 題目刷掉 7 成面試者
驚呆了!這些 Python 題目刷掉 7 成面試者驚呆了!這些 Python 題目刷掉 7 成面試者
驚呆了!這些 Python 題目刷掉 7 成面試者Chun-Yu Tseng
 
5 minutes 介紹台南拍 (2022 ver.)
5 minutes 介紹台南拍 (2022 ver.)5 minutes 介紹台南拍 (2022 ver.)
5 minutes 介紹台南拍 (2022 ver.)Chun-Yu Tseng
 
Tenet: 2020 Taiwan PyCon Host We How
Tenet: 2020 Taiwan PyCon Host We HowTenet: 2020 Taiwan PyCon Host We How
Tenet: 2020 Taiwan PyCon Host We HowChun-Yu Tseng
 
Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019
Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019 Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019
Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019 Chun-Yu Tseng
 
from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018Chun-Yu Tseng
 
程式 x 設計 @ MOPCON 2014
程式 x 設計 @ MOPCON 2014程式 x 設計 @ MOPCON 2014
程式 x 設計 @ MOPCON 2014Chun-Yu Tseng
 
介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展
介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展
介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展Chun-Yu Tseng
 
OO x Python @ Tainan.py x MOSUT x FP 2014.09.27
OO x Python  @ Tainan.py x MOSUT x FP 2014.09.27OO x Python  @ Tainan.py x MOSUT x FP 2014.09.27
OO x Python @ Tainan.py x MOSUT x FP 2014.09.27Chun-Yu Tseng
 
用路人小幫手 x 回報大改造 @ 2014 台南黑客松
用路人小幫手 x 回報大改造 @ 2014 台南黑客松用路人小幫手 x 回報大改造 @ 2014 台南黑客松
用路人小幫手 x 回報大改造 @ 2014 台南黑客松Chun-Yu Tseng
 
PyConAPAC2014 BoF Introduction
PyConAPAC2014 BoF IntroductionPyConAPAC2014 BoF Introduction
PyConAPAC2014 BoF IntroductionChun-Yu Tseng
 
PyConAPAC2014 Tainan.py 介紹
PyConAPAC2014 Tainan.py 介紹PyConAPAC2014 Tainan.py 介紹
PyConAPAC2014 Tainan.py 介紹Chun-Yu Tseng
 
暖場 @ Tainan.py 2013.11.30
暖場 @ Tainan.py 2013.11.30 暖場 @ Tainan.py 2013.11.30
暖場 @ Tainan.py 2013.11.30 Chun-Yu Tseng
 
API 文件大亂鬥 @ MOPCON 2013
API 文件大亂鬥 @ MOPCON 2013API 文件大亂鬥 @ MOPCON 2013
API 文件大亂鬥 @ MOPCON 2013Chun-Yu Tseng
 
暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28
暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28
暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28Chun-Yu Tseng
 

More from Chun-Yu Tseng (16)

驚呆了!這些 Python 題目刷掉 7 成面試者
驚呆了!這些 Python 題目刷掉 7 成面試者驚呆了!這些 Python 題目刷掉 7 成面試者
驚呆了!這些 Python 題目刷掉 7 成面試者
 
5 minutes 介紹台南拍 (2022 ver.)
5 minutes 介紹台南拍 (2022 ver.)5 minutes 介紹台南拍 (2022 ver.)
5 minutes 介紹台南拍 (2022 ver.)
 
Tenet: 2020 Taiwan PyCon Host We How
Tenet: 2020 Taiwan PyCon Host We HowTenet: 2020 Taiwan PyCon Host We How
Tenet: 2020 Taiwan PyCon Host We How
 
Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019
Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019 Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019
Build and Host Real-world Machine Learning Services from Scratch @ pycontw2019
 
from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018
 
導讀 Clean Code
導讀 Clean Code導讀 Clean Code
導讀 Clean Code
 
程式 x 設計 @ MOPCON 2014
程式 x 設計 @ MOPCON 2014程式 x 設計 @ MOPCON 2014
程式 x 設計 @ MOPCON 2014
 
介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展
介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展
介紹 MOSUT @ 2014.09.26 自由軟體開發與社群發展
 
OO x Python @ Tainan.py x MOSUT x FP 2014.09.27
OO x Python  @ Tainan.py x MOSUT x FP 2014.09.27OO x Python  @ Tainan.py x MOSUT x FP 2014.09.27
OO x Python @ Tainan.py x MOSUT x FP 2014.09.27
 
用路人小幫手 x 回報大改造 @ 2014 台南黑客松
用路人小幫手 x 回報大改造 @ 2014 台南黑客松用路人小幫手 x 回報大改造 @ 2014 台南黑客松
用路人小幫手 x 回報大改造 @ 2014 台南黑客松
 
Tip for Editors
Tip for EditorsTip for Editors
Tip for Editors
 
PyConAPAC2014 BoF Introduction
PyConAPAC2014 BoF IntroductionPyConAPAC2014 BoF Introduction
PyConAPAC2014 BoF Introduction
 
PyConAPAC2014 Tainan.py 介紹
PyConAPAC2014 Tainan.py 介紹PyConAPAC2014 Tainan.py 介紹
PyConAPAC2014 Tainan.py 介紹
 
暖場 @ Tainan.py 2013.11.30
暖場 @ Tainan.py 2013.11.30 暖場 @ Tainan.py 2013.11.30
暖場 @ Tainan.py 2013.11.30
 
API 文件大亂鬥 @ MOPCON 2013
API 文件大亂鬥 @ MOPCON 2013API 文件大亂鬥 @ MOPCON 2013
API 文件大亂鬥 @ MOPCON 2013
 
暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28
暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28
暖場與 Web 相關的小玩具 @ Tainan.py 2013.09.28
 

快快樂樂成為 Coding Ninja (by pytest) @ PyConAPAC2015

Editor's Notes

  1. 本演講講的是對開發者而言的測試