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

More Related Content

What's hot

Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
Derek Smith
 
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
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
Rohit Bisht
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
ikhwanhayat
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
Hoang Le
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practicesnickokiss
 
Agile testing
Agile testingAgile testing
Agile testing
Yogita patil
 
TDD refresher
TDD refresherTDD refresher
TDD refresher
Kerry Buckley
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
Joe Tremblay
 
"DevOps > CI+CD "
"DevOps > CI+CD ""DevOps > CI+CD "
"DevOps > CI+CD "
Innovation Roots
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
David Berliner
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
Lee Englestone
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
Abner Chih Yi Huang
 
Code coverage
Code coverageCode coverage
Code coverage
Return on Intelligence
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Sergey Podolsky
 
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
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
Francesco Garavaglia
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And MockingJoe Wilson
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
Knoldus Inc.
 
Automation testing & Unit testing
Automation testing & Unit testingAutomation testing & Unit testing
Automation testing & Unit testing
Kapil Rajpurohit
 

What's hot (20)

Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
Agile testing
Agile testingAgile testing
Agile testing
 
TDD refresher
TDD refresherTDD refresher
TDD refresher
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
"DevOps > CI+CD "
"DevOps > CI+CD ""DevOps > CI+CD "
"DevOps > CI+CD "
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
 
Code coverage
Code coverageCode coverage
Code coverage
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
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
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Automation testing & Unit testing
Automation testing & Unit testingAutomation testing & Unit testing
Automation testing & Unit testing
 

Similar to TDD (Test Driven Design)

Test driven development
Test driven developmentTest driven development
Test driven developmentJohn 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 Developmentbhochhi
 
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
 
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 - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
Justin Gordon
 

Similar to TDD (Test Driven Design) (20)

Test driven development
Test driven developmentTest driven development
Test driven development
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
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...
 
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
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
 
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
 
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)
 
Python and test
Python and testPython and test
Python and test
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
 
NET Code Testing
NET Code TestingNET Code Testing
NET Code Testing
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 

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

  1. Turnover in people Increase in complexity due to interactions between components of the system
  2. 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.