SlideShare a Scribd company logo
TEST DRIVEN
DEVELOPMENT/DESIGN
Presented By:
Eralp Erat
Pragmalinq - PRG
1
TEST-DRIVEN
DEVELOPMENT
2
ORIGIN
 Test-Driven Development is a core part of the
agile process formalized by Kent Beck called
eXtreme Programming (XP).
 XP originally had the rule to test everything that
could possibly break. Now, however, the
practice of testing in XP has evolved into Test-
Driven Development.“
 Do not need to adopt XP in order to practice TDD
and gain the benefit from it. 3
INTRODUCTION
 Traditional Approach
 Test last
 Problems with Traditional
 Errors in production
 Programmer moves onto other projects
 Test and code written by different programmers
 Tests based on outdated information
 Infrequent testing
 Fixes that create other problems
4
COST OF DEVELOPMENT
Time
C
o
s
t
Traditional
TDD
5
COST OF FIXING FAULTS
1
3
10
15
30
40
0
5
10
15
20
25
30
35
40
Reqs.
Design
Coding
Dev.Test
Accept.
Operation
Relative Cost
6
WHAT IS TDD?
 TDD is a technique whereby you write your test cases
before you write any implementation code
 Forces developers to think in terms of implementer and
user
 Tests drive or dictate the code that is developed
 “Do the simplest thing that could possibly work”
 Developers have less choice in what they write
 An indication of “intent”
 Tests provide a specification of “what” a piece of code
actually does – it goes some way to defining an interface
 Some might argue that “tests are part of the
documentation”
 Could your customers/clients write tests?
7
WHAT IS TDD?
 “Before you write code, think about what it will do.
Write a test that will use the methods you haven’t even
written yet.”
 A test is not something you “do”, it is something you
“write” and run once, twice, three times, etc.
 It is a piece of code
 Testing is therefore “automated”
 Repeatedly executed, even after small changes
 “TDD is risk averse programming, investing work in the
near term to avoid failures later on”
8
9
WHAT CAN BE TESTED?
 Valid Input
 In-valid Input
 Exceptions
 Boundary Conditions
 Everything that should be possible break.
10
ASPECTS OF TDD
 Features
 High level user requirements
 User story
 Customer Tests
 Customer identified acceptance tests
 Developer Tests
 Tests developed during software construction
11
METHODOLOGY
 Test first – Code last
 You may not write production code unless you’ve first
written a failing unit test
12
TDD STAGES
Write a test
Compile
Fix compile errors
Run test,
watch it fail
Write code
Run test,
watch it pass
Refactor code
(and test)
13
TDD STAGES
 The Extreme Programming Explored , Bill Wake describes
the test cycle:
1. Write a single test
2. Compile it. It shouldn’t compile because you’ve not written
the implementation code
3. Implement just enough code to get the test to compile
4. Run the test and see it fail
5. Implement just enough code to get the test to pass
6. Run the test and see it pass
7. Refactor for clarity and “once and only once”
8. Repeat
14
LIFE CYCLE
Write Test
Compile
Run & See the
Fail
Refactor As
Needed
15
WHY DOES TDD WORK?
 The (sometimes tedious) routine leads the
programmers to think about details they
otherwise don’t (because they’ve bitten off more
than they can chew)
 Specifically, test cases are thought through
before the programmer is allowed to think about
the “interesting part” of how to implement the
functionality
16
WHY DOES TDD WORK?
 Encourages “divide-and-conquer”
 Programmers are never scared to make a change
that might “break” the system
 The testing time that is often squeezed out of the
end of a traditional development cycle cannot be
squeezed out.
17
ADVANTAGES OF TDD
 TDD shortens the programming feedback loop
 TDD promotes the development of high-quality
code
 User requirements more easily understood
 Reduced interface misunderstandings
 TDD provides concrete evidence that your
software works
 Reduced software defect rates
 Better Code
 Less Debug Time.
18
DISADVANTAGES OF TDD
 Programmers like to code, not to test
 Test writing is time consuming
 TDD may not always work
19
EXAMPLE
 We want to develop a method that, given two
Integers, returns an Integer that is the sum of
parameters.
20
EXAMPLE (CONT.)
 Test
Integer i =
new Integer(5);
Integer j =
new Interger(2);
Object o = sum(i,j);
 Method
21
EXAMPLE (CONT.)
 Test
Integer i =
new Integer(5);
Integer j =
new Interger(2);
Object o = sum(i,j);
 Method
public static Object
sum(Integer i,
Integer j) {
return new
Object();
}
22
EXAMPLE (CONT.)
 Test
Integer i =
new Integer(5);
Integer j =
new Interger(2);
Object o = sum(i,j);
if (o instanceof
Integer)
return true;
else
return false;
 Method
public static Object
sum(Integer i,
Integer j) {
return new
Object();
}
23
EXAMPLE (CONT.)
 Test
Integer i =
new Integer(5);
Integer j =
new Interger(2);
Object o = sum(i,j);
if (o instanceof
Integer)
return true;
else
return false;
 Method
public static Integer
sum(Integer i,
Integer j) {
return new
Integer();
}
24
EXAMPLE (CONT.)
 Test
Integer i =
new Integer(5);
Integer j =
new Interger(2);
Object o = sum(i,j);
if ((o instanceof
Integer) &&
((new Integer(7))
.equals(o))
return true;
else
return false;
 Method
public static Integer
sum(Integer i,
Integer j) {
return new
Integer();
}
25
EXAMPLE (CONT.)
 Test
Integer i =
new Integer(5);
Integer j =
new Interger(2);
Object o = sum(i,j);
if ((o instanceof
Integer) &&
((new Integer(7))
.equals(o))
return true;
else
return false;
 Method
public static Integer
sum(Integer i,
Integer j) {
return new
Integer(
i.intValue() +
j.intValue());
}
26
TECHNIQUE
 Identify a “smallest possible” change to be made
 Implement test and (the one line of) code for that
change (see previous slide)
 Run all tests
 Save test and code together in source control
system
 Repeat
27
CONCLUSION
 More code has to be written using TDD but that isn’t
the bottleneck in Software Development
 Techniques have to be learned by developers and
enforced by managers
 User Interface testing is the hardest
 Resulting unit tests most valuable when run as part of
an automated build process
28
Ad

More Related Content

What's hot (20)

Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
John Blum
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Sachithra Gayan
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
Srinivas Katakam
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
Raghu Kiran
 
Software Testing Fundamentals
Software Testing FundamentalsSoftware Testing Fundamentals
Software Testing Fundamentals
Chankey Pathak
 
Sanity testing and smoke testing
Sanity testing and smoke testingSanity testing and smoke testing
Sanity testing and smoke testing
MUHAMMAD FARHAN ASLAM
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
harinderpisces
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
Dror Helper
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
Knoldus Inc.
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
ikhwanhayat
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
Mindfire Solutions
 
Agile testing
Agile testingAgile testing
Agile testing
Yogita patil
 
Introduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefIntroduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed Shreef
Ahmed Shreef
 
Manual testing ppt
Manual testing pptManual testing ppt
Manual testing ppt
Santosh Maranabasari
 
Types of software testing
Types of software testingTypes of software testing
Types of software testing
Testbytes
 
Software Testing 101
Software Testing 101Software Testing 101
Software Testing 101
QA Hannah
 
Manual testing interview question by INFOTECH
Manual testing interview question by INFOTECHManual testing interview question by INFOTECH
Manual testing interview question by INFOTECH
Pravinsinh
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
Test cases
Test casesTest cases
Test cases
Chandra Maddigapu
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
John Blum
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
Srinivas Katakam
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
Raghu Kiran
 
Software Testing Fundamentals
Software Testing FundamentalsSoftware Testing Fundamentals
Software Testing Fundamentals
Chankey Pathak
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
Dror Helper
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
ikhwanhayat
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
Mindfire Solutions
 
Introduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefIntroduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed Shreef
Ahmed Shreef
 
Types of software testing
Types of software testingTypes of software testing
Types of software testing
Testbytes
 
Software Testing 101
Software Testing 101Software Testing 101
Software Testing 101
QA Hannah
 
Manual testing interview question by INFOTECH
Manual testing interview question by INFOTECHManual testing interview question by INFOTECH
Manual testing interview question by INFOTECH
Pravinsinh
 

Similar to TDD (Test Driven Design) (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
guestc8093a6
 
Test driven development
Test driven developmentTest driven development
Test driven development
John Walsh
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
Babul Mirdha
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Rajesh Kumar
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
bhochhi
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Kumaresh Chandra Baruri
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
Pietro Di Bello
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
Gianluca Padovani
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
mCloud
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
UTC Fire & Security
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
Amr E. Mohamed
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years afterIan Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Python and test
Python and testPython and test
Python and test
Micron Technology
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
Binary Studio
 
NET Code Testing
NET Code TestingNET Code Testing
NET Code Testing
Kirill Miroshnichenko
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Consulthinkspa
 
Test driven development
Test driven developmentTest driven development
Test driven development
Sharafat Ibn Mollah Mosharraf
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
Xavi Hidalgo
 
Test Driven
Test DrivenTest Driven
Test Driven
Alex Chaffee
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
guestc8093a6
 
Test driven development
Test driven developmentTest driven development
Test driven development
John Walsh
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
Babul Mirdha
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Rajesh Kumar
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
bhochhi
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
Pietro Di Bello
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
Gianluca Padovani
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
mCloud
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
UTC Fire & Security
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
Amr E. Mohamed
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
Binary Studio
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Consulthinkspa
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
Xavi Hidalgo
 
Ad

Recently uploaded (20)

Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Ad

TDD (Test Driven Design)

  • 3. ORIGIN  Test-Driven Development is a core part of the agile process formalized by Kent Beck called eXtreme Programming (XP).  XP originally had the rule to test everything that could possibly break. Now, however, the practice of testing in XP has evolved into Test- Driven Development.“  Do not need to adopt XP in order to practice TDD and gain the benefit from it. 3
  • 4. INTRODUCTION  Traditional Approach  Test last  Problems with Traditional  Errors in production  Programmer moves onto other projects  Test and code written by different programmers  Tests based on outdated information  Infrequent testing  Fixes that create other problems 4
  • 6. COST OF FIXING FAULTS 1 3 10 15 30 40 0 5 10 15 20 25 30 35 40 Reqs. Design Coding Dev.Test Accept. Operation Relative Cost 6
  • 7. WHAT IS TDD?  TDD is a technique whereby you write your test cases before you write any implementation code  Forces developers to think in terms of implementer and user  Tests drive or dictate the code that is developed  “Do the simplest thing that could possibly work”  Developers have less choice in what they write  An indication of “intent”  Tests provide a specification of “what” a piece of code actually does – it goes some way to defining an interface  Some might argue that “tests are part of the documentation”  Could your customers/clients write tests? 7
  • 8. WHAT IS TDD?  “Before you write code, think about what it will do. Write a test that will use the methods you haven’t even written yet.”  A test is not something you “do”, it is something you “write” and run once, twice, three times, etc.  It is a piece of code  Testing is therefore “automated”  Repeatedly executed, even after small changes  “TDD is risk averse programming, investing work in the near term to avoid failures later on” 8
  • 9. 9
  • 10. WHAT CAN BE TESTED?  Valid Input  In-valid Input  Exceptions  Boundary Conditions  Everything that should be possible break. 10
  • 11. ASPECTS OF TDD  Features  High level user requirements  User story  Customer Tests  Customer identified acceptance tests  Developer Tests  Tests developed during software construction 11
  • 12. METHODOLOGY  Test first – Code last  You may not write production code unless you’ve first written a failing unit test 12
  • 13. TDD STAGES Write a test Compile Fix compile errors Run test, watch it fail Write code Run test, watch it pass Refactor code (and test) 13
  • 14. TDD STAGES  The Extreme Programming Explored , Bill Wake describes the test cycle: 1. Write a single test 2. Compile it. It shouldn’t compile because you’ve not written the implementation code 3. Implement just enough code to get the test to compile 4. Run the test and see it fail 5. Implement just enough code to get the test to pass 6. Run the test and see it pass 7. Refactor for clarity and “once and only once” 8. Repeat 14
  • 15. LIFE CYCLE Write Test Compile Run & See the Fail Refactor As Needed 15
  • 16. WHY DOES TDD WORK?  The (sometimes tedious) routine leads the programmers to think about details they otherwise don’t (because they’ve bitten off more than they can chew)  Specifically, test cases are thought through before the programmer is allowed to think about the “interesting part” of how to implement the functionality 16
  • 17. WHY DOES TDD WORK?  Encourages “divide-and-conquer”  Programmers are never scared to make a change that might “break” the system  The testing time that is often squeezed out of the end of a traditional development cycle cannot be squeezed out. 17
  • 18. ADVANTAGES OF TDD  TDD shortens the programming feedback loop  TDD promotes the development of high-quality code  User requirements more easily understood  Reduced interface misunderstandings  TDD provides concrete evidence that your software works  Reduced software defect rates  Better Code  Less Debug Time. 18
  • 19. DISADVANTAGES OF TDD  Programmers like to code, not to test  Test writing is time consuming  TDD may not always work 19
  • 20. EXAMPLE  We want to develop a method that, given two Integers, returns an Integer that is the sum of parameters. 20
  • 21. EXAMPLE (CONT.)  Test Integer i = new Integer(5); Integer j = new Interger(2); Object o = sum(i,j);  Method 21
  • 22. EXAMPLE (CONT.)  Test Integer i = new Integer(5); Integer j = new Interger(2); Object o = sum(i,j);  Method public static Object sum(Integer i, Integer j) { return new Object(); } 22
  • 23. EXAMPLE (CONT.)  Test Integer i = new Integer(5); Integer j = new Interger(2); Object o = sum(i,j); if (o instanceof Integer) return true; else return false;  Method public static Object sum(Integer i, Integer j) { return new Object(); } 23
  • 24. EXAMPLE (CONT.)  Test Integer i = new Integer(5); Integer j = new Interger(2); Object o = sum(i,j); if (o instanceof Integer) return true; else return false;  Method public static Integer sum(Integer i, Integer j) { return new Integer(); } 24
  • 25. EXAMPLE (CONT.)  Test Integer i = new Integer(5); Integer j = new Interger(2); Object o = sum(i,j); if ((o instanceof Integer) && ((new Integer(7)) .equals(o)) return true; else return false;  Method public static Integer sum(Integer i, Integer j) { return new Integer(); } 25
  • 26. EXAMPLE (CONT.)  Test Integer i = new Integer(5); Integer j = new Interger(2); Object o = sum(i,j); if ((o instanceof Integer) && ((new Integer(7)) .equals(o)) return true; else return false;  Method public static Integer sum(Integer i, Integer j) { return new Integer( i.intValue() + j.intValue()); } 26
  • 27. TECHNIQUE  Identify a “smallest possible” change to be made  Implement test and (the one line of) code for that change (see previous slide)  Run all tests  Save test and code together in source control system  Repeat 27
  • 28. CONCLUSION  More code has to be written using TDD but that isn’t the bottleneck in Software Development  Techniques have to be learned by developers and enforced by managers  User Interface testing is the hardest  Resulting unit tests most valuable when run as part of an automated build process 28

Editor's Notes

  • #6: Turnover in people Increase in complexity due to interactions between components of the system
  • #7: These were the minimum ratios, the maximum was 1000 to 1 between operation and requirements phases! Absolute costs are usually significantly greater than expected for faults found especially in the Operation phase (figures of $10,000 - $150000 are often quoted by organisations such as HP). Do you know what the typical rework cost (time/money) is for a fault reported by users in the field? It is these costs and those associated with rework from dynamic testing that are significantly reduced by using reviews - a static testing technique that is also more efficient at finding faults than dynamic testing in terms of faults found per hour of testing.
  翻译: