SlideShare a Scribd company logo
Test Driven
Development
Test Driven
Development
 Technique to design and develop software.
 Practice part of the Extreme Programming methodology — XP
 Based on three fundamental pillars.
TheThree
Pillars
 Implement the exact
functionality of the software.
 Reduce the number of defects
on the software – good quality
software
 Produce modular and highly
reusable software.
When Doing
TDD
 It’s not about just writing tests.
 Translate use cases to examples.
 Enough to describe the functionality without ambiguity.
 Architecture will eventually emerge.
TheTDD
Algorithm
Red
GreenRefactor
TheTDD
Algorithm
Red
GreenRefactor
TDD InAction
With an example ;-)
The Problem Email validation mechanism
The Problem
Email validation mechanism
The Problem
Email validation mechanism
Neither empty nor null.
Has to contain an @ symbol
Has to belong to the .com, .net and .eduTDLs
Domain part can’t be 1 character long
All lowercase
Not contain numbers
Only _ . - symbols
Before we
begin
WritingTests
 Testing framework
 Part of the language
 Ruby
 Rust
 Go
 Python
 External tools and libraries
TestNG
MSTest
Neither empty nor null
Red
@Test
public void shouldReturnFalseIfEmailIsNull() {
String email = null;
EmailValidator validator = new EmailValidator();
boolean isValid = validator.isValid(email);
assertThat(isValid, equalTo(false));
}
Neither empty nor null
Green public boolean isValid(String email) {
return false;
}
Neither empty nor null
Red
@Test
public void shouldReturnTrueIfEmailLengthIsGreaterThanZero() {
String email = "some@email.com";
EmailValidator validator = new EmailValidator();
boolean isValid = validator.isValid(email);
assertThat(isValid, equalTo(true));
}
Neither empty nor null
Green
public boolean isValid(String email) {
if (email == null) {
return false;
}
return email.length() > 0;
}
Contains an @ symbol
Red
@Test
public void shouldReturnFalseIfEmailDoesntContainAtSymbol () {
String email = "someemail.com";
EmailValidator validator = new EmailValidator();
boolean isValid = validator.isValid(email);
assertThat(isValid, equalTo(false));
}
Neither empty nor null
Green
public boolean isValid(String email) {
if (email == null) {
return false;
}
if (!email.contains("@")) {
return false;
}
return email.length() > 0;
}
Refactor
private EmailValidator validator;
@Before
public void setUp () {
validator = new EmailValidator();
}
In the end…
 Components will behave exactly as we want.
 Tests will be the documentation of our system.
 Tests will break if changes compromise the system.
Thank you!
Carlos Andrés Oquendo
coquendo@thoughtworks.com
@andres19_05

More Related Content

What's hot

Design concerns for concrete syntax
Design concerns for concrete syntaxDesign concerns for concrete syntax
Design concerns for concrete syntax
Mikhail Barash
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
RoyKlein
 
5 black box and grey box testing
5   black box and grey box testing5   black box and grey box testing
5 black box and grey box testing
Yisal Khan
 
White box testing
White box testingWhite box testing
White box testing
Neethu Tressa
 
White Box Testing
White Box TestingWhite Box Testing
White Box Testing
Alisha Roy
 
Black Box Testing Techniques by Sampath M
Black Box Testing Techniques by Sampath MBlack Box Testing Techniques by Sampath M
Black Box Testing Techniques by Sampath M
Forziatech
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
Myeongseok Baek
 
DISE - Programming Concepts
DISE - Programming ConceptsDISE - Programming Concepts
DISE - Programming Concepts
Rasan Samarasinghe
 
St 1.3
St 1.3St 1.3
Considered the brain of the computer gpu cpu/tutorialoutlet
Considered the brain of the computer gpu cpu/tutorialoutletConsidered the brain of the computer gpu cpu/tutorialoutlet
Considered the brain of the computer gpu cpu/tutorialoutlet
Danielsonz
 
Test-drive development and Umple
Test-drive development and UmpleTest-drive development and Umple
Test-drive development and Umple
tylerjdmcconnell
 
Python: Object-oriented Testing
Python: Object-oriented TestingPython: Object-oriented Testing
Python: Object-oriented Testing
Damian T. Gordon
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
phanleson
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
Facundo Farias
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
Cefalo
 
Implementing DSLs in practice
Implementing DSLs in practiceImplementing DSLs in practice
Implementing DSLs in practice
Mikhail Barash
 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard parts
Shaun Abram
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
Lee Englestone
 
DSLs: what, why, how
DSLs: what, why, howDSLs: what, why, how
DSLs: what, why, how
Mikhail Barash
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
jakejakejake2
 

What's hot (20)

Design concerns for concrete syntax
Design concerns for concrete syntaxDesign concerns for concrete syntax
Design concerns for concrete syntax
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
5 black box and grey box testing
5   black box and grey box testing5   black box and grey box testing
5 black box and grey box testing
 
White box testing
White box testingWhite box testing
White box testing
 
White Box Testing
White Box TestingWhite Box Testing
White Box Testing
 
Black Box Testing Techniques by Sampath M
Black Box Testing Techniques by Sampath MBlack Box Testing Techniques by Sampath M
Black Box Testing Techniques by Sampath M
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
DISE - Programming Concepts
DISE - Programming ConceptsDISE - Programming Concepts
DISE - Programming Concepts
 
St 1.3
St 1.3St 1.3
St 1.3
 
Considered the brain of the computer gpu cpu/tutorialoutlet
Considered the brain of the computer gpu cpu/tutorialoutletConsidered the brain of the computer gpu cpu/tutorialoutlet
Considered the brain of the computer gpu cpu/tutorialoutlet
 
Test-drive development and Umple
Test-drive development and UmpleTest-drive development and Umple
Test-drive development and Umple
 
Python: Object-oriented Testing
Python: Object-oriented TestingPython: Object-oriented Testing
Python: Object-oriented Testing
 
Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
 
Implementing DSLs in practice
Implementing DSLs in practiceImplementing DSLs in practice
Implementing DSLs in practice
 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard parts
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
DSLs: what, why, how
DSLs: what, why, howDSLs: what, why, how
DSLs: what, why, how
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
 

Viewers also liked

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
 
The Power of BDD
The Power of BDDThe Power of BDD
The Power of BDDNancy Cai
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
Amir Barylko
 
Introduction to Test Driven Development [TDD]
Introduction to Test Driven Development [TDD]Introduction to Test Driven Development [TDD]
Introduction to Test Driven Development [TDD]
Ashish K Agarwal
 
Test-Driven Development (TDD) - MSP Coding Day
Test-Driven Development (TDD) - MSP Coding DayTest-Driven Development (TDD) - MSP Coding Day
Test-Driven Development (TDD) - MSP Coding Day
Renato Groff
 
How to bdd with concordion
How to bdd with concordionHow to bdd with concordion
How to bdd with concordionAMikitas
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven DevelopmentJoshua Partogi
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
jakubkoci
 

Viewers also liked (10)

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
 
Selenium and Continuous Intergration
Selenium and Continuous IntergrationSelenium and Continuous Intergration
Selenium and Continuous Intergration
 
Bdd
BddBdd
Bdd
 
The Power of BDD
The Power of BDDThe Power of BDD
The Power of BDD
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Introduction to Test Driven Development [TDD]
Introduction to Test Driven Development [TDD]Introduction to Test Driven Development [TDD]
Introduction to Test Driven Development [TDD]
 
Test-Driven Development (TDD) - MSP Coding Day
Test-Driven Development (TDD) - MSP Coding DayTest-Driven Development (TDD) - MSP Coding Day
Test-Driven Development (TDD) - MSP Coding Day
 
How to bdd with concordion
How to bdd with concordionHow to bdd with concordion
How to bdd with concordion
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

Similar to Test Driven Development (TDD) Basics

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 Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
Dionatan default
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
Attila Bertók
 
Testing and symfony2
Testing and symfony2Testing and symfony2
Testing and symfony2
The Software House
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Kumaresh Chandra Baruri
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Tdd
TddTdd
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
L&T Technology Services Limited
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Babul Mirdha
 
How to complement TDD with static analysis
How to complement TDD with static analysisHow to complement TDD with static analysis
How to complement TDD with static analysis
PVS-Studio
 
Tdd
TddTdd
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
ESEM 2014
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
guestc8093a6
 
Presentation Test Driven Development
Presentation Test Driven DevelopmentPresentation Test Driven Development
Presentation Test Driven Development
Rashmi Srivastava
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Sachithra Gayan
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
nedirtv
 
TDD - survival guide
TDD - survival guide TDD - survival guide
TDD - survival guide vitalipe
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Anuj Arora
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development Introduction
Nguyen Hai
 

Similar to Test Driven Development (TDD) Basics (20)

Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Testing and symfony2
Testing and symfony2Testing and symfony2
Testing and symfony2
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Tdd
TddTdd
Tdd
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 
How to complement TDD with static analysis
How to complement TDD with static analysisHow to complement TDD with static analysis
How to complement TDD with static analysis
 
Tdd
TddTdd
Tdd
 
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Presentation Test Driven Development
Presentation Test Driven DevelopmentPresentation Test Driven Development
Presentation Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
 
TDD - survival guide
TDD - survival guide TDD - survival guide
TDD - survival guide
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development Introduction
 

Recently uploaded

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
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
 
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
 
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
 
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
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
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
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
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
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 

Recently uploaded (20)

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
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
 
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
 
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
 
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...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
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
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
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 -...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

Test Driven Development (TDD) Basics

  • 2. Test Driven Development  Technique to design and develop software.  Practice part of the Extreme Programming methodology — XP  Based on three fundamental pillars.
  • 3. TheThree Pillars  Implement the exact functionality of the software.  Reduce the number of defects on the software – good quality software  Produce modular and highly reusable software.
  • 4. When Doing TDD  It’s not about just writing tests.  Translate use cases to examples.  Enough to describe the functionality without ambiguity.  Architecture will eventually emerge.
  • 7. TDD InAction With an example ;-)
  • 8. The Problem Email validation mechanism
  • 10. The Problem Email validation mechanism Neither empty nor null. Has to contain an @ symbol Has to belong to the .com, .net and .eduTDLs Domain part can’t be 1 character long All lowercase Not contain numbers Only _ . - symbols
  • 11. Before we begin WritingTests  Testing framework  Part of the language  Ruby  Rust  Go  Python  External tools and libraries TestNG MSTest
  • 12. Neither empty nor null Red @Test public void shouldReturnFalseIfEmailIsNull() { String email = null; EmailValidator validator = new EmailValidator(); boolean isValid = validator.isValid(email); assertThat(isValid, equalTo(false)); }
  • 13. Neither empty nor null Green public boolean isValid(String email) { return false; }
  • 14. Neither empty nor null Red @Test public void shouldReturnTrueIfEmailLengthIsGreaterThanZero() { String email = "some@email.com"; EmailValidator validator = new EmailValidator(); boolean isValid = validator.isValid(email); assertThat(isValid, equalTo(true)); }
  • 15. Neither empty nor null Green public boolean isValid(String email) { if (email == null) { return false; } return email.length() > 0; }
  • 16. Contains an @ symbol Red @Test public void shouldReturnFalseIfEmailDoesntContainAtSymbol () { String email = "someemail.com"; EmailValidator validator = new EmailValidator(); boolean isValid = validator.isValid(email); assertThat(isValid, equalTo(false)); }
  • 17. Neither empty nor null Green public boolean isValid(String email) { if (email == null) { return false; } if (!email.contains("@")) { return false; } return email.length() > 0; }
  • 18. Refactor private EmailValidator validator; @Before public void setUp () { validator = new EmailValidator(); }
  • 19. In the end…  Components will behave exactly as we want.  Tests will be the documentation of our system.  Tests will break if changes compromise the system.
  • 20. Thank you! Carlos Andrés Oquendo coquendo@thoughtworks.com @andres19_05

Editor's Notes

  1. Design: * We normally rush to start coding a solution without thinking much about the problem itself.
  2. Exact functionality: *
  3. Examples: Traditionally we will code based on use cases that describe the functionality with natural language. Most of the times there is ambiguity expressed on them because of our language. The idea is to generate as much examples as needed in order to remove all the ambiguity. Architecture: Will emerge at a higher level. Depends on the type of application we are implementing and the technologies we are using. Not that we should not think on architectural decisions or concerns, but we will postpone them until they are necessary. Normally we design applications having several layers, transfer objects, factories and so on, but we may not need them. Freedom to the developer. In some contexts, all has to be coded the same way.
  4. Red We’ll start writing a test for a certain example. Why? Compilation errors Test failures Green We’ll implement the minimum possible functionality to cover the test case. We’ll be tempted to write a bit more code. We should be strong. Refactor We’ll revisit our test and implementation code to see if we can improve something without changing the functionality. What can we do? Clean the code Extract variables, Reduce duplication We should try to improve something, at least a bit. Sometimes it won’t be obvious, but we should spend a bit of time trying to refactor.
  5. What does email validation mean for this specific context? The fact is that validating an email, although sounds universal, may be very specific depending on the business context.
  6. To write tests we need some technology support, which is presented as a Testing Framework. Some languages and frameworks include some kind of unit testing support, such as … But in any case there are several unit testing frameworks we can use to write tests for our code, even if the language does provide some testing support. Just to name a few Java .NET JavaScript
  7. We’d like to refactor, but the code is so tiny…
  8. We’d like to refactor, but the code is so tiny…
  9. We’d like to refactor, but the code is so tiny…
  10. We’d like to refactor, but the code is so tiny…