SlideShare una empresa de Scribd logo
1 de 12
How we make tests

 Test 101
 ●




 Make better tests
 ●




 Write test friendly code
 ●




 When & Where we need tests
 ●




 Sth. else
 ●
Test 101

●   如何来测试我们的程序?
Test 101

●   使用代码测试比人更可靠


●   Unit tests, Functional tests, Intergration tests


●   如何开始我的测试 ?
Test 101

●   测试的基础 : 验证输入和输出是否符合期望值


●   Log, 单步调试 , '=', Equal, Assert … and so on


●   Demo1.
Make better tests

●   建立独立最小测试环境
    –   测试与代码分离
    –   Setup & Teardown
    –   独立的测试数据
Make better tests

●   再多一点
    –   独立的测试环境   environment[:test]
    –   专有的测试方法   testhelper
    –   有效的组织测试   rake, shell
    –   使用测试夹具    测试数据无需入库
Make better tests

●   依赖外部调用无法测试怎么办 ?
    –   网络不通 , 调用资金等
    –   其他模块出错 , 没开发完
    –   我就只想测试自己的部分 等等


●   Mock & Stub 帮助你
Write test friendly code

●   1 单一职责


●   2 接口分离


●   3 避免耦合太深
Write test friendly code

         圆桌讨论 : 怎样写出更容易测试的代码
When & Where we need tests

●   等我不忙了就加测试
    –   永远有下一个项目
    –   越后面成本 ( 包括时间 ) 越高 , 测试质量也越差
●   以前代码太难写测试了 , 等重构了再说
    –   测试是重构的基础
    –   新的代码还等以后才写测试 ?
When & Where we need tests

●   涉及到付费的        谁敢拿钱开玩笑
●   核心业务逻辑      一旦变化会影响多处地方
●   第三方集成       回归 , 你没法控制别人的变化
●   系统中容易变化的地方         测试让每次变化更安全
●   多个 object 协作的地方    每一个的变化都可能出错
●   代码晦涩,难以理解          增加测试是重构的第一步
●   很多判断的地方           逻辑复杂的代表
Sth. else

●   Watchr & Guard(base on ruby)   让测试守护你的程序


●   CI                    持续集成


●   TDD&BDD               测试 ( 行为 ) 驱动开发

Más contenido relacionado

Destacado

21. TCI Resilience Flagship Report 2012
21. TCI Resilience Flagship Report 201221. TCI Resilience Flagship Report 2012
21. TCI Resilience Flagship Report 2012Richard Plumpton
 
Berbicara dialektik
Berbicara dialektikBerbicara dialektik
Berbicara dialektikindhria
 
Optika geometri
Optika geometriOptika geometri
Optika geometrisupri Yono
 
NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)
NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)
NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)Richard Plumpton
 
введение в психогеометрию
введение в психогеометриювведение в психогеометрию
введение в психогеометриюmaster-sva
 
09a.TCI Sport_and_climate 2015
09a.TCI Sport_and_climate 201509a.TCI Sport_and_climate 2015
09a.TCI Sport_and_climate 2015Richard Plumpton
 
33rd IBCT Crosswire Issue 7
33rd IBCT Crosswire Issue 733rd IBCT Crosswire Issue 7
33rd IBCT Crosswire Issue 733rdibctpao
 
40 practice paper_3_h_-_set_c_mark_scheme
40 practice paper_3_h_-_set_c_mark_scheme40 practice paper_3_h_-_set_c_mark_scheme
40 practice paper_3_h_-_set_c_mark_schemeclaire meadows-smith
 
Einführung in Elasticsearch
Einführung in ElasticsearchEinführung in Elasticsearch
Einführung in ElasticsearchFlorian Hopf
 
More information about InnoSeal Systems
More information about InnoSeal  SystemsMore information about InnoSeal  Systems
More information about InnoSeal SystemsChristy_innoseal
 
The model of perfect competition
The model of perfect competitionThe model of perfect competition
The model of perfect competitionLin Zaw
 

Destacado (16)

21. TCI Resilience Flagship Report 2012
21. TCI Resilience Flagship Report 201221. TCI Resilience Flagship Report 2012
21. TCI Resilience Flagship Report 2012
 
Moral Fundamentalism
Moral FundamentalismMoral Fundamentalism
Moral Fundamentalism
 
Cracking the MBA
Cracking the MBACracking the MBA
Cracking the MBA
 
Leadership Templates
Leadership TemplatesLeadership Templates
Leadership Templates
 
Berbicara dialektik
Berbicara dialektikBerbicara dialektik
Berbicara dialektik
 
Profil MonaVie
Profil MonaVieProfil MonaVie
Profil MonaVie
 
Optika geometri
Optika geometriOptika geometri
Optika geometri
 
Where We End
Where We EndWhere We End
Where We End
 
NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)
NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)
NBT in the CT_Baseline Analysis_Jan 2016 Summary (LOW-RES)
 
введение в психогеометрию
введение в психогеометриювведение в психогеометрию
введение в психогеометрию
 
09a.TCI Sport_and_climate 2015
09a.TCI Sport_and_climate 201509a.TCI Sport_and_climate 2015
09a.TCI Sport_and_climate 2015
 
33rd IBCT Crosswire Issue 7
33rd IBCT Crosswire Issue 733rd IBCT Crosswire Issue 7
33rd IBCT Crosswire Issue 7
 
40 practice paper_3_h_-_set_c_mark_scheme
40 practice paper_3_h_-_set_c_mark_scheme40 practice paper_3_h_-_set_c_mark_scheme
40 practice paper_3_h_-_set_c_mark_scheme
 
Einführung in Elasticsearch
Einführung in ElasticsearchEinführung in Elasticsearch
Einführung in Elasticsearch
 
More information about InnoSeal Systems
More information about InnoSeal  SystemsMore information about InnoSeal  Systems
More information about InnoSeal Systems
 
The model of perfect competition
The model of perfect competitionThe model of perfect competition
The model of perfect competition
 

Similar a How+we+make+tests

使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)Max Lai
 
测试驱动的前端开发初探
测试驱动的前端开发初探测试驱动的前端开发初探
测试驱动的前端开发初探hua qiu
 
Test driven-frontend-develop
Test driven-frontend-developTest driven-frontend-develop
Test driven-frontend-developfangdeng
 
Angular Testing for Book Club Online of Angular Taiwan
Angular Testing for Book Club Online of Angular TaiwanAngular Testing for Book Club Online of Angular Taiwan
Angular Testing for Book Club Online of Angular Taiwan志龍 陳
 
Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)Fong Liou
 
2012 China 软件测试大会
2012 China 软件测试大会2012 China 软件测试大会
2012 China 软件测试大会mayun1688
 
unit test & performance optimization
unit test & performance optimizationunit test & performance optimization
unit test & performance optimizationSean Liu
 
Mobile app的測試v2
Mobile app的測試v2Mobile app的測試v2
Mobile app的測試v2Mr PM
 
2014/02: 嵌入式測試驅動開發
2014/02: 嵌入式測試驅動開發2014/02: 嵌入式測試驅動開發
2014/02: 嵌入式測試驅動開發AgileCommunity
 
敏捷自动化测试中的教训 45min 中文
敏捷自动化测试中的教训 45min   中文敏捷自动化测试中的教训 45min   中文
敏捷自动化测试中的教训 45min 中文Shuyong Lin
 
Foundation of software development 1
Foundation of software development 1Foundation of software development 1
Foundation of software development 1netdbncku
 
Tdd with rspec.md
Tdd with rspec.mdTdd with rspec.md
Tdd with rspec.mdLeo Chang
 
Codeception test
Codeception testCodeception test
Codeception testChin-Yu Ku
 
服务器基准测试-叶金荣@CYOU-20121130
服务器基准测试-叶金荣@CYOU-20121130服务器基准测试-叶金荣@CYOU-20121130
服务器基准测试-叶金荣@CYOU-20121130Jinrong Ye
 
有效的单元测试.ppt
有效的单元测试.ppt有效的单元测试.ppt
有效的单元测试.ppttest499702
 
從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)
從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)
從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)Rick Hwang
 
敏捷软件测试之简介
敏捷软件测试之简介敏捷软件测试之简介
敏捷软件测试之简介Yi Xu
 
Frank‘s Learning Summary - Agile testing
Frank‘s Learning Summary - Agile testingFrank‘s Learning Summary - Agile testing
Frank‘s Learning Summary - Agile testingFrank Lee
 
Ops as Code using Serverless
Ops as Code using Serverless Ops as Code using Serverless
Ops as Code using Serverless Rick Hwang
 

Similar a How+we+make+tests (20)

使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)
 
测试驱动的前端开发初探
测试驱动的前端开发初探测试驱动的前端开发初探
测试驱动的前端开发初探
 
Test driven-frontend-develop
Test driven-frontend-developTest driven-frontend-develop
Test driven-frontend-develop
 
Angular Testing for Book Club Online of Angular Taiwan
Angular Testing for Book Club Online of Angular TaiwanAngular Testing for Book Club Online of Angular Taiwan
Angular Testing for Book Club Online of Angular Taiwan
 
Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)
 
2012 China 软件测试大会
2012 China 软件测试大会2012 China 软件测试大会
2012 China 软件测试大会
 
unit test & performance optimization
unit test & performance optimizationunit test & performance optimization
unit test & performance optimization
 
Mobile app的測試v2
Mobile app的測試v2Mobile app的測試v2
Mobile app的測試v2
 
2014/02: 嵌入式測試驅動開發
2014/02: 嵌入式測試驅動開發2014/02: 嵌入式測試驅動開發
2014/02: 嵌入式測試驅動開發
 
敏捷自动化测试中的教训 45min 中文
敏捷自动化测试中的教训 45min   中文敏捷自动化测试中的教训 45min   中文
敏捷自动化测试中的教训 45min 中文
 
Foundation of software development 1
Foundation of software development 1Foundation of software development 1
Foundation of software development 1
 
Tdd with rspec.md
Tdd with rspec.mdTdd with rspec.md
Tdd with rspec.md
 
Codeception test
Codeception testCodeception test
Codeception test
 
服务器基准测试-叶金荣@CYOU-20121130
服务器基准测试-叶金荣@CYOU-20121130服务器基准测试-叶金荣@CYOU-20121130
服务器基准测试-叶金荣@CYOU-20121130
 
Xpp
XppXpp
Xpp
 
有效的单元测试.ppt
有效的单元测试.ppt有效的单元测试.ppt
有效的单元测试.ppt
 
從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)
從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)
從理想、到現實的距離,開啟品味軟體測試之路 - 台灣軟體工程協會 (20220813)
 
敏捷软件测试之简介
敏捷软件测试之简介敏捷软件测试之简介
敏捷软件测试之简介
 
Frank‘s Learning Summary - Agile testing
Frank‘s Learning Summary - Agile testingFrank‘s Learning Summary - Agile testing
Frank‘s Learning Summary - Agile testing
 
Ops as Code using Serverless
Ops as Code using Serverless Ops as Code using Serverless
Ops as Code using Serverless
 

How+we+make+tests

  • 1. How we make tests Test 101 ● Make better tests ● Write test friendly code ● When & Where we need tests ● Sth. else ●
  • 2. Test 101 ● 如何来测试我们的程序?
  • 3. Test 101 ● 使用代码测试比人更可靠 ● Unit tests, Functional tests, Intergration tests ● 如何开始我的测试 ?
  • 4. Test 101 ● 测试的基础 : 验证输入和输出是否符合期望值 ● Log, 单步调试 , '=', Equal, Assert … and so on ● Demo1.
  • 5. Make better tests ● 建立独立最小测试环境 – 测试与代码分离 – Setup & Teardown – 独立的测试数据
  • 6. Make better tests ● 再多一点 – 独立的测试环境 environment[:test] – 专有的测试方法 testhelper – 有效的组织测试 rake, shell – 使用测试夹具 测试数据无需入库
  • 7. Make better tests ● 依赖外部调用无法测试怎么办 ? – 网络不通 , 调用资金等 – 其他模块出错 , 没开发完 – 我就只想测试自己的部分 等等 ● Mock & Stub 帮助你
  • 8. Write test friendly code ● 1 单一职责 ● 2 接口分离 ● 3 避免耦合太深
  • 9. Write test friendly code 圆桌讨论 : 怎样写出更容易测试的代码
  • 10. When & Where we need tests ● 等我不忙了就加测试 – 永远有下一个项目 – 越后面成本 ( 包括时间 ) 越高 , 测试质量也越差 ● 以前代码太难写测试了 , 等重构了再说 – 测试是重构的基础 – 新的代码还等以后才写测试 ?
  • 11. When & Where we need tests ● 涉及到付费的 谁敢拿钱开玩笑 ● 核心业务逻辑 一旦变化会影响多处地方 ● 第三方集成 回归 , 你没法控制别人的变化 ● 系统中容易变化的地方 测试让每次变化更安全 ● 多个 object 协作的地方 每一个的变化都可能出错 ● 代码晦涩,难以理解 增加测试是重构的第一步 ● 很多判断的地方 逻辑复杂的代表
  • 12. Sth. else ● Watchr & Guard(base on ruby) 让测试守护你的程序 ● CI 持续集成 ● TDD&BDD 测试 ( 行为 ) 驱动开发