SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Add TDD to your toolbox 
an introduction for beginners 
Audrey Troutt @auditty
What is TDD? Test-Driven Development 
Audrey Troutt @auditty
Audrey Troutt @auditty 
Three conditions to achieve a flow state: 
1. clear set of goals and progress 
2. clear and immediate feedback 
3. confidence in one's ability 
Csikszentmihalyi, M.; Abuhamdeh, S. & Nakamura, J. (2005), "Flow", in Elliot, A., Handbook of Competence and Motivation
“TDD is dead. Long live testing.” 
-David Heinemeier Hansson 
Read more: http://bit.ly/1foLebI 
Audrey Troutt @auditty
Materials needed: 
Source code 
Unit testing framework 
Understanding of requirements 
Audrey Troutt @auditty
Simple Case: There’s a bug 
Audrey Troutt @auditty
Use Case: From the Ground Up 
Audrey Troutt @auditty
“As the tests get more specific, 
the code gets more generic.” 
-Uncle Bob Martin 
Read more: http://bit.ly/1Bs2h70 
Audrey Troutt @auditty
● ({}–>nil) no code at all->code that employs nil 
● (nil->constant) 
● (constant->constant+) a simple constant to a more complex constant 
● (constant->scalar) replacing a constant with a variable or an argument 
● (statement->statements) adding more unconditional statements. 
● (unconditional->if) splitting the execution path 
● (scalar->array) 
● (array->container) 
● (statement->recursion) 
● … and so on 
Read more: http://bit.ly/1Bs2h70 
Audrey Troutt @auditty
Pros: 
● More tests 
● More testable code 
● Discover missing 
requirements sooner 
● Uncover novel designs 
● Increased quality 
● Refactor/add on with 
confidence 
● Doesn’t generally take 
more time 
● May start conversations 
Cons: 
● First time setup of test 
framework takes extra 
time 
● Not always practical (if 
requirements are not 
well defined) 
● Makes changing object 
model harder 
● May start conversations 
Audrey Troutt @auditty
“I credit TDD for teaching me how to test, and I still get huge 
benefits when I TDD. It’s not perfect, but no one technique is the 
key to magically producing better code.” 
-Justin Weiss 
Read more: http://bit.ly/1BVRR1y 
Audrey Troutt @auditty
Practice 
http://codekata.com/ 
Learn from others 
http://katas.softwarecraftsmanship.org/ 
Audrey Troutt @auditty

Weitere ähnliche Inhalte

Andere mochten auch

TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecBen Mabey
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven developmenttoteb5
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Zohirul Alam Tiemoon
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 

Andere mochten auch (8)

TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
TDD Overview
TDD OverviewTDD Overview
TDD Overview
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpec
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 

Kürzlich hochgeladen

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Add TDD to your Toolbox: an introduction to TDD

  • 1. Add TDD to your toolbox an introduction for beginners Audrey Troutt @auditty
  • 2. What is TDD? Test-Driven Development Audrey Troutt @auditty
  • 3. Audrey Troutt @auditty Three conditions to achieve a flow state: 1. clear set of goals and progress 2. clear and immediate feedback 3. confidence in one's ability Csikszentmihalyi, M.; Abuhamdeh, S. & Nakamura, J. (2005), "Flow", in Elliot, A., Handbook of Competence and Motivation
  • 4. “TDD is dead. Long live testing.” -David Heinemeier Hansson Read more: http://bit.ly/1foLebI Audrey Troutt @auditty
  • 5. Materials needed: Source code Unit testing framework Understanding of requirements Audrey Troutt @auditty
  • 6. Simple Case: There’s a bug Audrey Troutt @auditty
  • 7. Use Case: From the Ground Up Audrey Troutt @auditty
  • 8. “As the tests get more specific, the code gets more generic.” -Uncle Bob Martin Read more: http://bit.ly/1Bs2h70 Audrey Troutt @auditty
  • 9. ● ({}–>nil) no code at all->code that employs nil ● (nil->constant) ● (constant->constant+) a simple constant to a more complex constant ● (constant->scalar) replacing a constant with a variable or an argument ● (statement->statements) adding more unconditional statements. ● (unconditional->if) splitting the execution path ● (scalar->array) ● (array->container) ● (statement->recursion) ● … and so on Read more: http://bit.ly/1Bs2h70 Audrey Troutt @auditty
  • 10. Pros: ● More tests ● More testable code ● Discover missing requirements sooner ● Uncover novel designs ● Increased quality ● Refactor/add on with confidence ● Doesn’t generally take more time ● May start conversations Cons: ● First time setup of test framework takes extra time ● Not always practical (if requirements are not well defined) ● Makes changing object model harder ● May start conversations Audrey Troutt @auditty
  • 11. “I credit TDD for teaching me how to test, and I still get huge benefits when I TDD. It’s not perfect, but no one technique is the key to magically producing better code.” -Justin Weiss Read more: http://bit.ly/1BVRR1y Audrey Troutt @auditty
  • 12. Practice http://codekata.com/ Learn from others http://katas.softwarecraftsmanship.org/ Audrey Troutt @auditty

Hinweis der Redaktion

  1. April 2014 - this was dropped at RailsConf Test-first fundamentalism is ...an unrealistic, ineffective morality campaign for self-loathing and shaming. The gist of his argument is that we don’t need TDD anymore, it makes us sad, our object models become too complex and indirect, we can write isolated system tests that verify the business requirements. All respect to Mr Hansson, but I don’t agree with all of his points. He amplified a conversation that has been going on since TDD first came into wide use about whether it is useful at all. I leave that up to you, but I will say try it for yourself before you decide. Anyway, I’m not here to promote any particular testing religion. I see TDD as just another tool to use. I don’t use it all the time, in fact I use it pretty rarely these days. But, I have learned a lot about testing from having practiced TDD over the years and every now and then it is just the right tool for the job.
  2. So now that we’ve covered an overview and where TDD stands as a practice in use today, let’s talk about how to get started.
  3. I had a bug about a month ago: code to calculate the minutes from GMT for people who are currently experiencing X local time. I had TDD’d it, but I got it wrong. So, I wrote a failing test (in fact fixed a bad expectation in an existing test) and then went to the production code and got it to pass. Refactored, added another new test case, and refactored again. Two or three cycles and I was done. It was probably no more than 15 minutes. This is the most common case that I use TDD for these days. There are two benefits (besides just fixing the bug): 1) you are sure that you fixed the bug because you wrote a test that replicated the failure that you saw in production and 2) you have the test as an artifact, so that bug can never happen again!
  4. That’s a quick and simple use case, but where TDD really shines is when you are working from the ground up. New feature, new algorithm. What does it look like to use TDD to build from nothing?