SlideShare a Scribd company logo
Testing In Software Engineering
Kian Saha
f
i - Spring 2023
Testing Software - TDD
"Professional developers test their code. But testing is not simply a matter of writing a few unit tests or a few acceptance tests.
Writing these tests is a good thing, but it is far from suf
fi
cient. What every professional development team needs is a good
testing strategy. “
-Robert C. Martin
Testing Strategies
The Test Automation Pyramid
Professional developers employ the discipline of Test Driven Development
to create unit tests. Professional development teams use acceptance tests
to specify their system, and continuous integration to prevent regression.
The Test Automation Pyramid
Or Junit (For Java)
This Figure shows the Test Automation Pyramid,2 a graphical depiction of the kinds of tests
that a professional development organization needs.
Unit Test
• At the bottom of the pyramid are the unit tests. These tests are written by
programmers, for programmers, in the programming language of the
system. The intent of these tests is to specify the system at the lowest
level. Developers write these tests before writing production code as a
way to specify what they are about to write. They are executed as part of
Continuous Integration to ensure that the intent of the programmers’ is
upheld.
• Unit tests provide as close to 100% coverage as is practical. Generally this
number should be somewhere in the 90s. And it should be true coverage
as opposed to false tests that execute code without asserting its behavior.
Component Tests
• Generally they are written against individual components of the system. The components of
the system encapsulate the business rules, so the tests for those components are the
acceptance tests for those business rules.
• As depicted in this Figure a component test wraps a component. It passes input data into
the component and gathers output data from it. It tests that the output matches the input.
Any other system components are decoupled from the test using appropriate mocking and
test-doubling techniques.
• Component tests are written by QA and Business with assistance from development. They are
composed in a component-testing environment such as FITNESSE, JBehave, or Cucumber.
(GUI components are tested with GUI testing environments such as Selenium or Watir.) The
intent is that the business should be able to read and interpret these tests, if not author them.
• Component tests cover roughly half the system. They are directed more towards happy-path
situations and very obvious corner, boundary, and alternate-path cases. The vast majority of
unhappy-path cases are covered by unit tests and are meaningless at the level of component
tests.
Integration Tests
• These tests only have meaning for larger systems that have many components. As
shown in the Figure, these tests assemble groups of components and test how well
they communicate with each other. The other components of the system are
decoupled as usual with appropriate mocks and test-doubles.
• Integration tests are choreography tests. They do not test business rules. Rather, they
test how well the assembly of components dances together. They are plumbing tests
that make sure that the components are properly connected and can clearly
communicate with each other.
• Integration tests are typically written by the system architects, or lead designers, of
the system. The tests ensure that the architectural structure of the system is sound. It
is at this level that we might see performance and throughput tests.
• Integration tests are typically written in the same language and environment as
component tests. They are typically not executed as part of the Continuous
Integration suite, because they often have longer runtimes. Instead, these tests are
run periodically (nightly, weekly, etc.) as deemed necessary by their authors.
System Tests
• These are automated tests that execute against the entire integrated system. They are
the ultimate integration tests. They do not test business rules directly. Rather, they test
that the system has been wired together correctly and its parts interoperate according
to plan. We would expect to see throughput and performance tests in this suite.
• These tests are written by the system architects and technical leads. Typically they are
written in the same language and environment as integration tests for the UI. They are
executed relatively infrequently depending on their duration, but the more frequently
the better.
• System tests cover perhaps 10% of the system. This is because their intent is not to
ensure correct system behavior, but correct system construction. The correct behavior
of the underlying code and components have already been ascertained by the lower
layers of the pyramid.
Manual Exploratory Tests
• This is where humans put their hands on the keyboards and their eyes on the screens.
These tests are not automated, nor are they scripted. The intent of these tests is to explore
the system for unexpected behaviors while con
f
irming expected behaviors. Toward that
end we need human brains, with human creativity, working to investigate and explore the
system. Creating a written test plan for this kind of testing defeats the purpose.
• Some teams will have specialists do this work. Other teams will simply declare a day or two
of “bug hunting” in which as many people as possible, including managers, secretaries,
programmers, testers, and tech writers, “bang” on the system to see if they can make it
break.
• The goal is not coverage. We are not going to prove out every business rule and every
execution pathway with these tests. Rather, the goal is to ensure that the system behaves
well under human operation and to creatively
f
ind as many “peculiarities” as possible.
What the Heck is TDD?
And why am I hearing this much about it?
• It has been over ten years since Test Driven Development (TDD) made its
debut in the industry. It came in as part of the Extreme Programming (XP)
wave, but has since been adopted by Scrum, and virtually all of the other
Agile methods. Even non-Agile teams practice TDD.
The Three Laws of TDD
1. You are not allowed to write any production code until you have
f
irst
written a failing unit test.
2. You are not allowed to write more of a unit test than is su
ff
icient to fail —
and not compiling is failing.
3. You are not allowed to write more production code that is su
ff
icient to
pass the currently failing unit test.
The Litany Of Bene
f
its
Is TDD any good?
Certainty
Defect Injection Rate
Courage
Documentation
Design
What if I write my tests later?
How certain? Certain enough to ship!
FITNESSE has 64,000 lines of code,
With 2,200 individual unit tests
With 90% coverage!
mission-critical application?
teams have experienced defect reductions
of 2X, 5X, and even 10X
Why don’t you
fi
x bad code when you see it?
what if you could be sure that your cleaning
did not break anything? When programmers lose the fear of cleaning, they clean!
third-party framework
Each of the unit tests you write is an example,
written in code, describing how the system should be used
The problem with testing code
is that you have to isolate that code
But the tests you write after the fact are defense.
The tests you write
fi
rst are o
ff
ense.
forces you to think about good design
What TDD is Not!
• For all its good points, TDD is not a religion or a magic formula. Following
the three laws does not guarantee any of these bene
f
its. You can still write
bad code even if you write your tests
f
irst. Indeed, you can write bad
tests.
• By the same token, there are times when following the three laws is simply
impractical or inappropriate. These situations are rare, but they exist.
•
Let’s code…
Didn’t Get any of it?
No problem. ;-)
Reference: Clean Coder - Robert C. Martin

More Related Content

Similar to Testing In Software Engineering

Week 14 Unit Testing.pptx
Week 14  Unit Testing.pptxWeek 14  Unit Testing.pptx
Week 14 Unit Testing.pptx
mianshafa
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing
Mary Clemons
 
utplsql.pdf
utplsql.pdfutplsql.pdf
utplsql.pdf
vijayv991893
 
Object Oriented Testing
Object Oriented TestingObject Oriented Testing
Object Oriented Testing
AMITJain879
 
Tdd dev session
Tdd dev sessionTdd dev session
Tdd dev session
Danyllo Albuquerque
 
Object oriented sad 6
Object oriented sad 6Object oriented sad 6
Object oriented sad 6
Bisrat Girma
 
Software Testing - SDLC Model
Software Testing - SDLC ModelSoftware Testing - SDLC Model
softwaretestingppt-120810095500-phpapp02 (1).pdf
softwaretestingppt-120810095500-phpapp02 (1).pdfsoftwaretestingppt-120810095500-phpapp02 (1).pdf
softwaretestingppt-120810095500-phpapp02 (1).pdf
BabaShaikh3
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
medsherb
 
Software test life cycle
Software test life cycleSoftware test life cycle
Software testing
Software testingSoftware testing
softwaretestingppt-FINAL-PPT-1
softwaretestingppt-FINAL-PPT-1softwaretestingppt-FINAL-PPT-1
softwaretestingppt-FINAL-PPT-1
FAIZALSAIYED
 
Stm unit1
Stm unit1Stm unit1
Stm unit1
Chaitanya Kn
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
Attila Bertók
 
What is integration testing
What is integration testingWhat is integration testing
What is integration testing
TestingXperts
 
Software testing
Software testingSoftware testing
Software testing
Ashu Bansal
 
L software testing
L   software testingL   software testing
L software testing
Fáber D. Giraldo
 
Bridging the communication gap
Bridging the communication gapBridging the communication gap
Bridging the communication gap
Guillagui San
 
Software Testing
Software TestingSoftware Testing
Software Testing
Vishal Singh
 
Implementing a testing strategy
Implementing a testing strategyImplementing a testing strategy
Implementing a testing strategy
Daniel Giraldo
 

Similar to Testing In Software Engineering (20)

Week 14 Unit Testing.pptx
Week 14  Unit Testing.pptxWeek 14  Unit Testing.pptx
Week 14 Unit Testing.pptx
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing
 
utplsql.pdf
utplsql.pdfutplsql.pdf
utplsql.pdf
 
Object Oriented Testing
Object Oriented TestingObject Oriented Testing
Object Oriented Testing
 
Tdd dev session
Tdd dev sessionTdd dev session
Tdd dev session
 
Object oriented sad 6
Object oriented sad 6Object oriented sad 6
Object oriented sad 6
 
Software Testing - SDLC Model
Software Testing - SDLC ModelSoftware Testing - SDLC Model
Software Testing - SDLC Model
 
softwaretestingppt-120810095500-phpapp02 (1).pdf
softwaretestingppt-120810095500-phpapp02 (1).pdfsoftwaretestingppt-120810095500-phpapp02 (1).pdf
softwaretestingppt-120810095500-phpapp02 (1).pdf
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 
Software test life cycle
Software test life cycleSoftware test life cycle
Software test life cycle
 
Software testing
Software testingSoftware testing
Software testing
 
softwaretestingppt-FINAL-PPT-1
softwaretestingppt-FINAL-PPT-1softwaretestingppt-FINAL-PPT-1
softwaretestingppt-FINAL-PPT-1
 
Stm unit1
Stm unit1Stm unit1
Stm unit1
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
What is integration testing
What is integration testingWhat is integration testing
What is integration testing
 
Software testing
Software testingSoftware testing
Software testing
 
L software testing
L   software testingL   software testing
L software testing
 
Bridging the communication gap
Bridging the communication gapBridging the communication gap
Bridging the communication gap
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Implementing a testing strategy
Implementing a testing strategyImplementing a testing strategy
Implementing a testing strategy
 

Recently uploaded

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 

Recently uploaded (20)

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 

Testing In Software Engineering

  • 1. Testing In Software Engineering Kian Saha f i - Spring 2023 Testing Software - TDD
  • 2. "Professional developers test their code. But testing is not simply a matter of writing a few unit tests or a few acceptance tests. Writing these tests is a good thing, but it is far from suf fi cient. What every professional development team needs is a good testing strategy. “ -Robert C. Martin
  • 3. Testing Strategies The Test Automation Pyramid Professional developers employ the discipline of Test Driven Development to create unit tests. Professional development teams use acceptance tests to specify their system, and continuous integration to prevent regression.
  • 4. The Test Automation Pyramid Or Junit (For Java) This Figure shows the Test Automation Pyramid,2 a graphical depiction of the kinds of tests that a professional development organization needs.
  • 5. Unit Test • At the bottom of the pyramid are the unit tests. These tests are written by programmers, for programmers, in the programming language of the system. The intent of these tests is to specify the system at the lowest level. Developers write these tests before writing production code as a way to specify what they are about to write. They are executed as part of Continuous Integration to ensure that the intent of the programmers’ is upheld. • Unit tests provide as close to 100% coverage as is practical. Generally this number should be somewhere in the 90s. And it should be true coverage as opposed to false tests that execute code without asserting its behavior.
  • 6. Component Tests • Generally they are written against individual components of the system. The components of the system encapsulate the business rules, so the tests for those components are the acceptance tests for those business rules. • As depicted in this Figure a component test wraps a component. It passes input data into the component and gathers output data from it. It tests that the output matches the input. Any other system components are decoupled from the test using appropriate mocking and test-doubling techniques. • Component tests are written by QA and Business with assistance from development. They are composed in a component-testing environment such as FITNESSE, JBehave, or Cucumber. (GUI components are tested with GUI testing environments such as Selenium or Watir.) The intent is that the business should be able to read and interpret these tests, if not author them. • Component tests cover roughly half the system. They are directed more towards happy-path situations and very obvious corner, boundary, and alternate-path cases. The vast majority of unhappy-path cases are covered by unit tests and are meaningless at the level of component tests.
  • 7. Integration Tests • These tests only have meaning for larger systems that have many components. As shown in the Figure, these tests assemble groups of components and test how well they communicate with each other. The other components of the system are decoupled as usual with appropriate mocks and test-doubles. • Integration tests are choreography tests. They do not test business rules. Rather, they test how well the assembly of components dances together. They are plumbing tests that make sure that the components are properly connected and can clearly communicate with each other. • Integration tests are typically written by the system architects, or lead designers, of the system. The tests ensure that the architectural structure of the system is sound. It is at this level that we might see performance and throughput tests. • Integration tests are typically written in the same language and environment as component tests. They are typically not executed as part of the Continuous Integration suite, because they often have longer runtimes. Instead, these tests are run periodically (nightly, weekly, etc.) as deemed necessary by their authors.
  • 8. System Tests • These are automated tests that execute against the entire integrated system. They are the ultimate integration tests. They do not test business rules directly. Rather, they test that the system has been wired together correctly and its parts interoperate according to plan. We would expect to see throughput and performance tests in this suite. • These tests are written by the system architects and technical leads. Typically they are written in the same language and environment as integration tests for the UI. They are executed relatively infrequently depending on their duration, but the more frequently the better. • System tests cover perhaps 10% of the system. This is because their intent is not to ensure correct system behavior, but correct system construction. The correct behavior of the underlying code and components have already been ascertained by the lower layers of the pyramid.
  • 9. Manual Exploratory Tests • This is where humans put their hands on the keyboards and their eyes on the screens. These tests are not automated, nor are they scripted. The intent of these tests is to explore the system for unexpected behaviors while con f irming expected behaviors. Toward that end we need human brains, with human creativity, working to investigate and explore the system. Creating a written test plan for this kind of testing defeats the purpose. • Some teams will have specialists do this work. Other teams will simply declare a day or two of “bug hunting” in which as many people as possible, including managers, secretaries, programmers, testers, and tech writers, “bang” on the system to see if they can make it break. • The goal is not coverage. We are not going to prove out every business rule and every execution pathway with these tests. Rather, the goal is to ensure that the system behaves well under human operation and to creatively f ind as many “peculiarities” as possible.
  • 10. What the Heck is TDD? And why am I hearing this much about it? • It has been over ten years since Test Driven Development (TDD) made its debut in the industry. It came in as part of the Extreme Programming (XP) wave, but has since been adopted by Scrum, and virtually all of the other Agile methods. Even non-Agile teams practice TDD.
  • 11. The Three Laws of TDD 1. You are not allowed to write any production code until you have f irst written a failing unit test. 2. You are not allowed to write more of a unit test than is su ff icient to fail — and not compiling is failing. 3. You are not allowed to write more production code that is su ff icient to pass the currently failing unit test.
  • 12. The Litany Of Bene f its Is TDD any good? Certainty Defect Injection Rate Courage Documentation Design What if I write my tests later? How certain? Certain enough to ship! FITNESSE has 64,000 lines of code, With 2,200 individual unit tests With 90% coverage! mission-critical application? teams have experienced defect reductions of 2X, 5X, and even 10X Why don’t you fi x bad code when you see it? what if you could be sure that your cleaning did not break anything? When programmers lose the fear of cleaning, they clean! third-party framework Each of the unit tests you write is an example, written in code, describing how the system should be used The problem with testing code is that you have to isolate that code But the tests you write after the fact are defense. The tests you write fi rst are o ff ense. forces you to think about good design
  • 13. What TDD is Not! • For all its good points, TDD is not a religion or a magic formula. Following the three laws does not guarantee any of these bene f its. You can still write bad code even if you write your tests f irst. Indeed, you can write bad tests. • By the same token, there are times when following the three laws is simply impractical or inappropriate. These situations are rare, but they exist. •
  • 14. Let’s code… Didn’t Get any of it? No problem. ;-) Reference: Clean Coder - Robert C. Martin