SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Hicham El Hammouchi
@helhammo
www.hichamelhammouchi.com
https://github.com/melxx001
§ Introduction
§ What is a unit test?
§ What is TDD?
§ Why use TDD?
§ TDD Misconceptions
§ Are Unit test Useless?
§ What’s a good unit test?
§ Unit vs functional vs Integration
§ How to start TDD at work
§ Summary
§ Demo
§ Tests are the first line of the defense
§ Enhance documentation
§ Help design your code
§ Help in refactoring, adding, modifying or removing features
§ Help in preventing broken builds to production
§ Help in developer understand the component requirement
§ Very clearly defined purpose and set of attributes
§ ONE specific requirement for ONE specific method
§ Targeted
§ Isolated
§ Repeatable
§ Independent
§ Encourages Simplification
§ "Test-driven development (TDD) is a software development process that relies on
the repetition of a very short development cycle: requirements are turned into very
specific test cases, then the software is improved to pass the new tests, only." -
WikipediA
§ Write a failing test (Red)
§ Implement the code and make the test pass (Green)
§ Refactor (If needed)
§ TDD reduces production bug density by 40–80% (based on studies)
§ Reduces maintenance costs
§ Increase developer productivity in the long term
§ Encourage more modular design
§ Reduces code complexity
§ Reduces the interruption of the normal flow of software development
§ It's too time consuming
§ You can't write test until you know the design and implement the code
§ You have to write all tests before you write the code
§ Everything needs unit tests
§ Brittle tests
§ Complicated tests
§ Ignored Tests
§ Follow Best Practices
§ Robust tests
§ Do and Learn
§ Design aid
§ Feature documentation
§ QA/Continuous Delivery
§ Good Bug Report
§ Exact location of issue
§ Quick
§ Ideally, test would run constantly
§ Which component was tested?
§ What is the expected behavior?
§ What's the expected result?
§ What was the actual output?
§ How can the test be reproduced?
§ Unit tests ensure that individual components of the app work as expected
§ Integration tests ensure that component collaborations work as expected
§ Functional tests ensure that the app works as expected from the user’s perspective
§ Ideally, we'd start a new project with TDD
§ Start a new task with unit tests
§ Fix bugs with unit tests if possible
§ TDD
§ Write a failing test (Red)
§ Implement the code and make the test pass (Green)
§ Refactor (If needed)
§ Guidelines of successful tests
§ One assertion per test
§ Test output produces clear documentation
§ Tests are simple and understandable at a glance
§ Tests are treated like code
§ Which component was tested?
§ What is the expected behavior?
§ What's the expected result?
§ What was the actual output?
§ How can the test be reprod uced?
§ TDD does not replace architecture or Design
§ TDD will inform and validate (or not) your design
§ Weakness and flaws in design will be uncovered
§ Finding bugs in development is much better than finding them in production
§ “Perfect is the enemy of good.”Voltaire
§ 5 Questions Every Unit Test Must Answer - https://medium.com/javascript-
scene/what-every-unit-test-needs-f6cd34d9836d
§ 5 Common Misconceptions About TDD & Unit Tests -
https://medium.com/javascript-scene/5-common-misconceptions-about-
tdd-unit-tests-863d5beb3ce9
§ Empirical Studies Show Test Driven Development Improves Quality -
https://www.infoq.com/news/2009/03/TDD-Improves-Quality
Test Driven Development
Test Driven Development

Contenu connexe

Tendances

Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanQA or the Highway
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...Steve Lange
 
Impression from Geecon 2014
Impression from Geecon 2014 Impression from Geecon 2014
Impression from Geecon 2014 Adamsus
 
Continuous business goal validation
Continuous business goal validationContinuous business goal validation
Continuous business goal validationHylke Stapersma
 
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...Steve Lange
 
Continuous delivery test strategies
Continuous delivery test strategiesContinuous delivery test strategies
Continuous delivery test strategiesHylke Stapersma
 
TLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingTLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingAnna Royzman
 
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang GottesheimPerformance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang GottesheimJAXLondon2014
 
Agile Testing in Enterprise: Way to transform - SQA Days 2014
Agile Testing in Enterprise: Way to transform - SQA Days 2014Agile Testing in Enterprise: Way to transform - SQA Days 2014
Agile Testing in Enterprise: Way to transform - SQA Days 2014Andrey Rebrov
 
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieHey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieQA or the Highway
 
How testers add value to the organization appium conf
How testers add value to the organization  appium confHow testers add value to the organization  appium conf
How testers add value to the organization appium confCorina Pip
 
The Essentials Of Test Driven Development
The Essentials Of Test Driven Development The Essentials Of Test Driven Development
The Essentials Of Test Driven Development Rock Interview
 
Automation testing in Agile project
Automation testing in Agile projectAutomation testing in Agile project
Automation testing in Agile projectHien Nguyen
 
Testing: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like itTesting: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like itJeffrey McGuire
 
Test Driven Development by Sameer Arora
Test Driven Development by Sameer AroraTest Driven Development by Sameer Arora
Test Driven Development by Sameer AroraXebia IT Architects
 
Become Software Tester or Developer
Become Software Tester or DeveloperBecome Software Tester or Developer
Become Software Tester or DeveloperKMS Technology
 
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015][XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]Agile đây Vietnam
 
Improving the Quality of Incoming Code
Improving the Quality of Incoming CodeImproving the Quality of Incoming Code
Improving the Quality of Incoming CodeNaresh Jain
 

Tendances (20)

Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh EastmanBehavior Driven Development—A Guide to Agile Practices by Josh Eastman
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
 
Impression from Geecon 2014
Impression from Geecon 2014 Impression from Geecon 2014
Impression from Geecon 2014
 
Continuous business goal validation
Continuous business goal validationContinuous business goal validation
Continuous business goal validation
 
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
 
Continuous delivery test strategies
Continuous delivery test strategiesContinuous delivery test strategies
Continuous delivery test strategies
 
TLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingTLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing Testing
 
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang GottesheimPerformance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
 
Agile Testing in Enterprise: Way to transform - SQA Days 2014
Agile Testing in Enterprise: Way to transform - SQA Days 2014Agile Testing in Enterprise: Way to transform - SQA Days 2014
Agile Testing in Enterprise: Way to transform - SQA Days 2014
 
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieHey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
 
Test pyramid
Test pyramidTest pyramid
Test pyramid
 
Agileee 2012
Agileee 2012Agileee 2012
Agileee 2012
 
How testers add value to the organization appium conf
How testers add value to the organization  appium confHow testers add value to the organization  appium conf
How testers add value to the organization appium conf
 
The Essentials Of Test Driven Development
The Essentials Of Test Driven Development The Essentials Of Test Driven Development
The Essentials Of Test Driven Development
 
Automation testing in Agile project
Automation testing in Agile projectAutomation testing in Agile project
Automation testing in Agile project
 
Testing: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like itTesting: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like it
 
Test Driven Development by Sameer Arora
Test Driven Development by Sameer AroraTest Driven Development by Sameer Arora
Test Driven Development by Sameer Arora
 
Become Software Tester or Developer
Become Software Tester or DeveloperBecome Software Tester or Developer
Become Software Tester or Developer
 
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015][XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
 
Improving the Quality of Incoming Code
Improving the Quality of Incoming CodeImproving the Quality of Incoming Code
Improving the Quality of Incoming Code
 

Similaire à Test Driven Development

Unit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonUnit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonSeb Rose
 
Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Vijay Kumbhar
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development CodeOps Technologies LLP
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017Xavi Hidalgo
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In ActionJon Kruger
 
TDD and BDD in Sky Deutschland
TDD and BDD in Sky DeutschlandTDD and BDD in Sky Deutschland
TDD and BDD in Sky DeutschlandMurphy Meng
 
Cleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven DevelopmentCleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven DevelopmentAll Things Open
 
TDD and Unit Testing in Golang
TDD and Unit Testing in GolangTDD and Unit Testing in Golang
TDD and Unit Testing in GolangSofian Hadiwijaya
 

Similaire à Test Driven Development (20)

JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Unit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking SkeletonUnit Testing, TDD and the Walking Skeleton
Unit Testing, TDD and the Walking Skeleton
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
Testing in java
Testing in javaTesting in java
Testing in java
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
TDD
TDDTDD
TDD
 
Tdd
TddTdd
Tdd
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD and BDD in Sky Deutschland
TDD and BDD in Sky DeutschlandTDD and BDD in Sky Deutschland
TDD and BDD in Sky Deutschland
 
Cleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven DevelopmentCleaner Code Through Test-Driven Development
Cleaner Code Through Test-Driven Development
 
TDD and Unit Testing in Golang
TDD and Unit Testing in GolangTDD and Unit Testing in Golang
TDD and Unit Testing in Golang
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
Tdd
TddTdd
Tdd
 

Dernier

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 

Dernier (20)

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 

Test Driven Development

  • 2. § Introduction § What is a unit test? § What is TDD? § Why use TDD? § TDD Misconceptions § Are Unit test Useless? § What’s a good unit test? § Unit vs functional vs Integration § How to start TDD at work § Summary § Demo
  • 3. § Tests are the first line of the defense § Enhance documentation § Help design your code § Help in refactoring, adding, modifying or removing features § Help in preventing broken builds to production § Help in developer understand the component requirement
  • 4. § Very clearly defined purpose and set of attributes § ONE specific requirement for ONE specific method
  • 5. § Targeted § Isolated § Repeatable § Independent § Encourages Simplification
  • 6. § "Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests, only." - WikipediA
  • 7. § Write a failing test (Red) § Implement the code and make the test pass (Green) § Refactor (If needed)
  • 8. § TDD reduces production bug density by 40–80% (based on studies) § Reduces maintenance costs § Increase developer productivity in the long term § Encourage more modular design § Reduces code complexity § Reduces the interruption of the normal flow of software development
  • 9. § It's too time consuming § You can't write test until you know the design and implement the code § You have to write all tests before you write the code § Everything needs unit tests
  • 10. § Brittle tests § Complicated tests § Ignored Tests
  • 11. § Follow Best Practices § Robust tests § Do and Learn
  • 12. § Design aid § Feature documentation § QA/Continuous Delivery
  • 13. § Good Bug Report § Exact location of issue
  • 14. § Quick § Ideally, test would run constantly
  • 15. § Which component was tested? § What is the expected behavior? § What's the expected result? § What was the actual output? § How can the test be reproduced?
  • 16. § Unit tests ensure that individual components of the app work as expected § Integration tests ensure that component collaborations work as expected § Functional tests ensure that the app works as expected from the user’s perspective
  • 17. § Ideally, we'd start a new project with TDD § Start a new task with unit tests § Fix bugs with unit tests if possible
  • 18. § TDD § Write a failing test (Red) § Implement the code and make the test pass (Green) § Refactor (If needed)
  • 19. § Guidelines of successful tests § One assertion per test § Test output produces clear documentation § Tests are simple and understandable at a glance § Tests are treated like code
  • 20. § Which component was tested? § What is the expected behavior? § What's the expected result? § What was the actual output? § How can the test be reprod uced?
  • 21. § TDD does not replace architecture or Design § TDD will inform and validate (or not) your design § Weakness and flaws in design will be uncovered § Finding bugs in development is much better than finding them in production § “Perfect is the enemy of good.”Voltaire
  • 22. § 5 Questions Every Unit Test Must Answer - https://medium.com/javascript- scene/what-every-unit-test-needs-f6cd34d9836d § 5 Common Misconceptions About TDD & Unit Tests - https://medium.com/javascript-scene/5-common-misconceptions-about- tdd-unit-tests-863d5beb3ce9 § Empirical Studies Show Test Driven Development Improves Quality - https://www.infoq.com/news/2009/03/TDD-Improves-Quality

Notes de l'éditeur

  1. We all know that we should write unit tests to prevent defects but a lot of us don't really know the essential ingredients of unit testing.   To have something reliable and durable, you can't just grab things and see if it fits together. There are specification to each component of the system. There are checkpoints to make sure each part of the system is successful Each individual component Interaction of groups of component Workings as a whole Tests are the first line of the defense and will ensure the success of application. In addition of making sure the system is working correctly, test can also: Enhance existing (or not) documentation by showing an example of implementation Help design your code Help in refactoring, adding, modifying or removing features Help in preventing broken builds to production Help in developer understand the component requirement. The difficult things and surprises are tackled early on
  2. Before we can get into a discussion of exactly what TDD is and how it works, it’s important to have a common and defined understanding about what a unit test is. A unit test is a very specific type of test with a very clearly defined purpose and set of attributes. It tests ONE specific requirement for ONE specific method
  3. They have the following attributes: Targeted: test one thing, one set of inputs at a time Isolated: The code tested should be isolated (from other code and external dependencies or events) Repeatable/Predictable: if the code and test did not change, running the test any amount of time will produce the same result Independent: Unit tests should be able to be run in any order. They should not expect or require that they follow a certain sequence Encourages Simplification: If the testing of the function is too complex then most likely the function is doing too much
  4. "Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests, only." - Wikipedia
  5. So: Write a failing test (Usually displayed in Red) Implement the code and make the test pass (Usually displayed in Green) Refactor (If some issue with performance or really bad code)
  6. The benefits of TDD have been tested on real projects by companies like Microsoft and IBM, and they found that the TDD process is enormously beneficial. Check out https://www.infoq.com/news/2009/03/TDD-Improves-Quality TDD reduces production bug density by 40–80%. Says 90% in study. Reduces maintenance costs: The teams' management reported subjectively a 15–35% increase in initial development time for the teams using TDD, though the teams agreed that this was offset by reduced maintenance costs Increase developer productivity in the long term Encourage more modular design Reduces code complexity Reduces the interruption of the normal flow of software development Increase things like user retention, increase of users (Probably not at C1) Reduce customer abandonment (Probably not at C1) Reduce the costs of customer service (probably not at C1)
  7. I hear this all the time: It's too time consuming: While the process adds 10%-30% to initial development, over time, when you factor maintenance, bug fixes rewrites, this offsets in maintenance costs You can't write test until you know the design and implement the code. Studies have concluded that writing tests first is more effective than adding tests later (TDD reduces production bug density by 40–90%). TDD forces you have a direction in mind before you start and having a better direction leads to better design You have to write all tests before you write the code. Not true. We try things and explore options until we get the result we want Everything needs unit tests: If you have to do a lot of mocking, perhaps that code doesn’t need a unit test. Maybe a functional tests would be better.
  8. Badly designed and written tests can cause more pain than help. The trouble with tests: You can have Brittle tests: easy to break You can have Complicated tests: Cost developer time to understand the test Ignored Tests: When test repeatedly fails, developers loose confidence in validity and mark them as ignored. It happens all the time with false positives.
  9. How to make them work Follow Best Practices: Write tests like real code Robust tests: Test the right things Do and Learn Code, code, code The more you code, the easier it gets
  10. So what’s a good unit test? Features Design aid: written during design phase, prior to implementation Feature documentation & test of developer understanding: The test should provide a clear description of the feature being tested QA/Continuous Delivery: The tests should halt the delivery pipeline on failure and produce a good bug report when they fail
  11. Need a good bug report The failure report should be able to show you exactly what failed and where to look
  12. Built for speed Running test should be quick and simple. Ideally, constantly running in the background.
  13. Questions to ask These are the 5 questions a unit test should easily answer when you look at it Which component was tested? What is the expected behavior? What's the expected result? What was the actual output? How can the test be reproduced?
  14. Unit tests ensure that individual components of the app work as expected. Assertions test the component API Integration tests ensure that component collaborations work as expected. Assertions may test component API, UI, or side-effects (such as database I/O, logging, etc.…) Functional tests ensure that the app works as expected from the user’s perspective. Assertions primarily test the user interface
  15. For your current project, how do you start TDD? Ideally, we'd start a new project with TDD Start a new task with unit tests Fix bugs with unit tests if possible
  16. In summary, TDD is a good process to deliver better quality code and gives more confidence in delivery The TDD cycle is: Write a failing test (Red) Implement the code and make the test pass (Green) Refactor (If some issue with performance or really bad code)
  17. One assertion per test (except when it makes sense. For example, checking if a function exists and is not null) If many things are tested at once, you'll have to unravel the results The test can become difficult to understand (show good test vs crappy test) Test output produces clear documentation Naming the test with a specific naming convention (what's been tested, test conditions, expectation) Tests are simple and understandable at a glance Should be able to look at it and understand it immediately Shouldn't be branching & looping Tests are treated like code: refactored, optimized and improved Easy to maintain & extend Don't repeat yourself
  18. Questions to ask These are the 5 questions a unit test should easily answer when you look at it Which component was tested? What is the expected behavior? What's the expected result? What was the actual output? How can the test be reproduced?
  19. It’s a learning curve and it takes time to get the hang of it. A lot of times, it’s takes discipline to do it. Especially when you have deadlines and someone breathing down your neck. TDD does not replace architecture or Design (You need to do some up front design and have a vision) TDD will inform and validate (or not) your design Weakness and flaws in design will be uncovered Finding bugs in development is much better than finding them in production “Perfect is the enemy of good.” Voltaire