Add TDD to your Toolbox: an introduction to TDD

A
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
1 of 12

Recommended

Introduction to TDD by
Introduction to TDDIntroduction to TDD
Introduction to TDDGil Zilberfeld
662 views14 slides
TDD Introduction with Kata FizzBuzz by
TDD Introduction with Kata FizzBuzzTDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzRick Liu
406 views14 slides
Tdd - introduction by
Tdd - introductionTdd - introduction
Tdd - introductionSamad Koushan
1.5K views41 slides
Test Driven Development (C#) by
Test Driven Development (C#)Test Driven Development (C#)
Test Driven Development (C#)Alan Dean
3.1K views57 slides
Introduction to TDD and Mocking by
Introduction to TDD and MockingIntroduction to TDD and Mocking
Introduction to TDD and Mockingsaeed shargi ghazani
4K views24 slides
Introduction to TDD (Test Driven development) - Ahmed Shreef by
Introduction to TDD (Test Driven development) - Ahmed ShreefIntroduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefAhmed Shreef
1.4K views32 slides

More Related Content

Viewers also liked

TDD And Refactoring by
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
7.4K views34 slides
TDD - Test Driven Development by
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
4.1K views38 slides
TDD Overview by
TDD OverviewTDD Overview
TDD OverviewNaresh Jain
7.4K views135 slides
The WHY behind TDD/BDD and the HOW with RSpec by
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
7K views99 slides
Scrum and Test-driven development by
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven developmenttoteb5
11.3K views16 slides
Test-Driven Development (TDD) by
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
9.7K views55 slides

Viewers also liked(8)

TDD And Refactoring by Naresh Jain
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
Naresh Jain7.4K views
The WHY behind TDD/BDD and the HOW with RSpec by Ben Mabey
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
Ben Mabey7K views
Scrum and Test-driven development by toteb5
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
toteb511.3K views
Test-Driven Development (TDD) by Brian Rasmussen
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
Brian Rasmussen9.7K views
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve... by Zohirul Alam Tiemoon
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 Tiemoon16.3K views
Test Driven Development (TDD) by David Ehringer
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
David Ehringer31.9K views

Recently uploaded

Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... by
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...NUS-ISS
28 views70 slides
[2023] Putting the R! in R&D.pdf by
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
38 views127 slides
The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
73 views25 slides
AMAZON PRODUCT RESEARCH.pdf by
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdfJerikkLaureta
15 views13 slides
The Importance of Cybersecurity for Digital Transformation by
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital TransformationNUS-ISS
27 views26 slides
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeNUS-ISS
19 views47 slides

Recently uploaded(20)

Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... by NUS-ISS
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
NUS-ISS28 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views
The Importance of Cybersecurity for Digital Transformation by NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS27 views
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by NUS-ISS
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
NUS-ISS19 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software225 views
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor... by Vadym Kazulkin
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
Vadym Kazulkin75 views
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 views
How the World's Leading Independent Automotive Distributor is Reinventing Its... by NUS-ISS
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...
NUS-ISS15 views
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV by Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk88 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 views
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... by NUS-ISS
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
NUS-ISS16 views
AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... by NUS-ISS
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
NUS-ISS37 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi120 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10209 views

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

Editor's Notes

  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?