SlideShare a Scribd company logo
1 of 26
Download to read offline
Test & Behavior
Driven
Development
or how to work with tests
March 27 2015
Legacy code VS innovation
Costofchange
Time
Low technical debt High technical debt
Test-Driven Development
What is a unit test?
“A unit test is an automated piece of code that
checks a single assumption about the behavior
of a unit of work”
artofunittesting.com
Sooo… what is a unit of work?
“A unit of work can span a single method, a
whole class or multiple classes working
together to achieve one single logical purpose
that can be verified”
artofunittesting.com
Example of Unit Test: DateTest
TEST 1: EMPTY DATE
Empty string, null or 0
are not valid parameters
and should return 0.
TEST 2: VALID DATE
time() is a valid
parameter and should
return a valid date.
Example of Unit Test: DateTest
class DateTest extends PHPUnit_Framework_TestCase
{
public function testEmptyDate()
{
$this->assertEquals(Date::getInstance('')->getTime(), 0, 'empty time returns 0');
$this->assertEquals(Date::getInstance(null)->getTime(), 0, 'null time returns 0');
$this->assertEquals(Date::getInstance(0)->getTime(), 0, 'zeroified time returns 0');
$this->assertNotEquals(Date::getInstance('')->getTime(), '', 'empty time does not
output to empty string');
}
}
real test written is PHP using PHPUnit Framework
The rules of Test-Driven Development
(Re)write a unit test
Run
the test
Write the code
Run all
tests
Refactor &
move on
it succeeds
all tests
succeed
it fails
it fails
repeat
for both core & front developers
ship the story
TDD is a good approach
Time spent on tickets but…
Level of confidence that can be placed into it
Risk of introducing regressions
Working with legacy code is safer
but it’s not enough
• Tech-oriented tests
• It doesn’t explain what the feature should do
• A ticket can pass the tests and still break the
user experience
but it’s not enough
Business goals
Squad projects
User stories
Something is
missing here
Code
Levelofdetails
Unit tests
Company level
Squad level
Story level
Behavior-Driven Development
What is a functional test?
“A functional test (or e2e test) is an automated
way of checking software to ensure that it has
all the required functionality that’s specified
within its functional requirements”
techopedia.com
Principles of Behavior-Driven Development
1. BDD focuses on
the behavioural
aspect of the
feature rather
than its
implementation.
2. BDD gives a clear
understanding as
to what a feature
should do from
technical,
business/product
and customer
standpoints.
3. BDD allows both
the developer and
product owner to
work together on
requirements
analysis.
Behavior-Driven Development
Write the test cases
Run all
tests
Refactor &
move on
all tests
succeed
it fails
Write the code
ship the story
“A [role] can [do something] 

(so that [benefits]).”
But… what does it do exactly?
User story
“(If [given state],) when [event], 

then it should [do something].”
Acceptance criteria and scenarii
Continue with scenario 2…
new
How to work with BDD
Business goals
Squad projects
User stories
Acceptance criteria
Scenarii
Code
Levelofdetails
Unit tests
Company level
Squad level
Story level
How to work with BDD
User Story:
A [role]

can [do something] 

so that [benefits]
Acceptance criteria:
Scenario 1:
If [given state]
and [other state]

when [event] 

then it should [do something]
and [another thing]
Scenario 2
Scenario 3
Other tests:
Scenario 4
Scenario 5
(Unit tests)
User stories remain the same
Acceptance criteria are the mandatory tests to validate the
story.
They should be written by both the product owner and the
developer before they start working on the ticket
Other tests are not here to validate the feature but to avoid
regressions and should test specific parts of the experience
Unit tests should not be described in the story, but present in
the code
Does this feature really need tests?
YES
so don’t forget to include them into the ticket
estimate, it costs time
Does this bug really need tests?
MAYBE
if it’s a recurrent or critical/blocker bug, you should
consider creating a test to avoid it
Example of story: Upload a video
A user can publish a video on his channel in order to increase his popularity.
SCENARIO 1
If the user is logged-in,
when he selects a video
file, it should upload it.
SCENARIO 2
If the user just selected a
video and fulfilled its
meta-data, when the
upload process is
completed, it should
publish the video.
SCENARIO 3
If the video is published,
when the user goes to its
player page, it should
display the video.
Upload a video: scenario 1
describe 'Upload a video', ->
it 'should upload a video', ->
uploadPage = new UploadPage()
login uploadPage.url
today = new Date()
videoName = 'Cool video for tests ' + today
uploadPage.uploadFile videoName
browser.sleep 3000
browser.getTitle().then (text) ->
expect(text).toEqual videoName
real test written is CoffeeScript using Jasmine Framework
Story life cycle
BEFORE
• Describe the acceptance
criteria in the ticket (dev
+ product)
WHILE
• The front developer needs to
implement acceptance criteria
alongside with the feature
code + some other tests (but
they are not required for the
feature validation)
• The core developer also needs
to implement unit tests for his
methods
AFTER
• The release process launches
all the acceptance criteria of
all features on a regular basis
to test all tickets together
release processall tests OK
What to do if a test fails?
Fix the feature
yes
no
Is the test still
relevant?
Rewrite the test Remove the test &
plan a feature killing
is the
feature still
relevant?
yes no
Thank you

More Related Content

What's hot

Tutorial of web application load testing in selinium
Tutorial of web application load testing in seliniumTutorial of web application load testing in selinium
Tutorial of web application load testing in seliniumKevalkumar Shah
 
Testing Java applications with Maveryx
Testing Java applications with MaveryxTesting Java applications with Maveryx
Testing Java applications with MaveryxMaveryx
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Deepak Singhvi
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven DevelopmentPablo Villar
 
Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for AndroidHazem Saleh
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 
General technical interview questions
General technical interview questionsGeneral technical interview questions
General technical interview questionsKevalkumar Shah
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
DotNet unit testing training
DotNet unit testing trainingDotNet unit testing training
DotNet unit testing trainingTom Tang
 
Introducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test AutomationIntroducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test AutomationTechWell
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiFlorent Batard
 
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 2010guest5639fa9
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testingalessiopace
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Babul Mirdha
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testingmalcolmt
 
Impact Analysis - LoopConf
Impact Analysis - LoopConfImpact Analysis - LoopConf
Impact Analysis - LoopConfChris Lema
 

What's hot (20)

Tutorial of web application load testing in selinium
Tutorial of web application load testing in seliniumTutorial of web application load testing in selinium
Tutorial of web application load testing in selinium
 
Testing Java applications with Maveryx
Testing Java applications with MaveryxTesting Java applications with Maveryx
Testing Java applications with Maveryx
 
QTP/UFT latest interview questions 2014
QTP/UFT latest interview questions 2014QTP/UFT latest interview questions 2014
QTP/UFT latest interview questions 2014
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
General technical interview questions
General technical interview questionsGeneral technical interview questions
General technical interview questions
 
Unit test
Unit testUnit test
Unit test
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
DotNet unit testing training
DotNet unit testing trainingDotNet unit testing training
DotNet unit testing training
 
Introducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test AutomationIntroducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test Automation
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansai
 
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
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)Test Driven iOS Development (TDD)
Test Driven iOS Development (TDD)
 
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAUTest Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testing
 
Impact Analysis - LoopConf
Impact Analysis - LoopConfImpact Analysis - LoopConf
Impact Analysis - LoopConf
 

Similar to Test-Driven Development and Behavior-Driven Development (TDD & BDD

Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Fwdays
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by ExampleNalin Goonawardana
 
TestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorialTestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorialLee Seungjong
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinSigma Software
 
Test driven development
Test driven developmentTest driven development
Test driven developmentlukaszkujawa
 
Software Testing interview - Q&A and tips
Software Testing interview - Q&A and tipsSoftware Testing interview - Q&A and tips
Software Testing interview - Q&A and tipsPankaj Dubey
 
Test driven development
Test driven developmentTest driven development
Test driven developmentnamkha87
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1Albert Rosa
 
Acceptance Testing With Selenium
Acceptance Testing With SeleniumAcceptance Testing With Selenium
Acceptance Testing With Seleniumelliando dias
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Visual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonVisual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonMek Srunyu Stittri
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example usingIevgenii Katsan
 
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 + EclipseUTC Fire & Security
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringromanovfedor
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMSJustinHolt20
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 

Similar to Test-Driven Development and Behavior-Driven Development (TDD & BDD (20)

Fundamentals of unit testing
Fundamentals of unit testingFundamentals of unit testing
Fundamentals of unit testing
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
TestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorialTestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorial
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita Galkin
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Software Testing interview - Q&A and tips
Software Testing interview - Q&A and tipsSoftware Testing interview - Q&A and tips
Software Testing interview - Q&A and tips
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
UI Testing
UI TestingUI Testing
UI Testing
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1
 
Acceptance Testing With Selenium
Acceptance Testing With SeleniumAcceptance Testing With Selenium
Acceptance Testing With Selenium
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Visual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonVisual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot Comparison
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example using
 
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
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discovering
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMS
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 

Recently uploaded

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 

Recently uploaded (20)

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

Test-Driven Development and Behavior-Driven Development (TDD & BDD

  • 1. Test & Behavior Driven Development or how to work with tests March 27 2015
  • 2. Legacy code VS innovation Costofchange Time Low technical debt High technical debt
  • 4. What is a unit test? “A unit test is an automated piece of code that checks a single assumption about the behavior of a unit of work” artofunittesting.com
  • 5. Sooo… what is a unit of work? “A unit of work can span a single method, a whole class or multiple classes working together to achieve one single logical purpose that can be verified” artofunittesting.com
  • 6. Example of Unit Test: DateTest TEST 1: EMPTY DATE Empty string, null or 0 are not valid parameters and should return 0. TEST 2: VALID DATE time() is a valid parameter and should return a valid date.
  • 7. Example of Unit Test: DateTest class DateTest extends PHPUnit_Framework_TestCase { public function testEmptyDate() { $this->assertEquals(Date::getInstance('')->getTime(), 0, 'empty time returns 0'); $this->assertEquals(Date::getInstance(null)->getTime(), 0, 'null time returns 0'); $this->assertEquals(Date::getInstance(0)->getTime(), 0, 'zeroified time returns 0'); $this->assertNotEquals(Date::getInstance('')->getTime(), '', 'empty time does not output to empty string'); } } real test written is PHP using PHPUnit Framework
  • 8. The rules of Test-Driven Development (Re)write a unit test Run the test Write the code Run all tests Refactor & move on it succeeds all tests succeed it fails it fails repeat for both core & front developers ship the story
  • 9. TDD is a good approach Time spent on tickets but… Level of confidence that can be placed into it Risk of introducing regressions Working with legacy code is safer
  • 10. but it’s not enough • Tech-oriented tests • It doesn’t explain what the feature should do • A ticket can pass the tests and still break the user experience
  • 11. but it’s not enough Business goals Squad projects User stories Something is missing here Code Levelofdetails Unit tests Company level Squad level Story level
  • 13. What is a functional test? “A functional test (or e2e test) is an automated way of checking software to ensure that it has all the required functionality that’s specified within its functional requirements” techopedia.com
  • 14. Principles of Behavior-Driven Development 1. BDD focuses on the behavioural aspect of the feature rather than its implementation. 2. BDD gives a clear understanding as to what a feature should do from technical, business/product and customer standpoints. 3. BDD allows both the developer and product owner to work together on requirements analysis.
  • 15. Behavior-Driven Development Write the test cases Run all tests Refactor & move on all tests succeed it fails Write the code ship the story
  • 16. “A [role] can [do something] 
 (so that [benefits]).” But… what does it do exactly? User story
  • 17. “(If [given state],) when [event], 
 then it should [do something].” Acceptance criteria and scenarii Continue with scenario 2… new
  • 18. How to work with BDD Business goals Squad projects User stories Acceptance criteria Scenarii Code Levelofdetails Unit tests Company level Squad level Story level
  • 19. How to work with BDD User Story: A [role]
 can [do something] 
 so that [benefits] Acceptance criteria: Scenario 1: If [given state] and [other state]
 when [event] 
 then it should [do something] and [another thing] Scenario 2 Scenario 3 Other tests: Scenario 4 Scenario 5 (Unit tests) User stories remain the same Acceptance criteria are the mandatory tests to validate the story. They should be written by both the product owner and the developer before they start working on the ticket Other tests are not here to validate the feature but to avoid regressions and should test specific parts of the experience Unit tests should not be described in the story, but present in the code
  • 20. Does this feature really need tests? YES so don’t forget to include them into the ticket estimate, it costs time
  • 21. Does this bug really need tests? MAYBE if it’s a recurrent or critical/blocker bug, you should consider creating a test to avoid it
  • 22. Example of story: Upload a video A user can publish a video on his channel in order to increase his popularity. SCENARIO 1 If the user is logged-in, when he selects a video file, it should upload it. SCENARIO 2 If the user just selected a video and fulfilled its meta-data, when the upload process is completed, it should publish the video. SCENARIO 3 If the video is published, when the user goes to its player page, it should display the video.
  • 23. Upload a video: scenario 1 describe 'Upload a video', -> it 'should upload a video', -> uploadPage = new UploadPage() login uploadPage.url today = new Date() videoName = 'Cool video for tests ' + today uploadPage.uploadFile videoName browser.sleep 3000 browser.getTitle().then (text) -> expect(text).toEqual videoName real test written is CoffeeScript using Jasmine Framework
  • 24. Story life cycle BEFORE • Describe the acceptance criteria in the ticket (dev + product) WHILE • The front developer needs to implement acceptance criteria alongside with the feature code + some other tests (but they are not required for the feature validation) • The core developer also needs to implement unit tests for his methods AFTER • The release process launches all the acceptance criteria of all features on a regular basis to test all tickets together release processall tests OK
  • 25. What to do if a test fails? Fix the feature yes no Is the test still relevant? Rewrite the test Remove the test & plan a feature killing is the feature still relevant? yes no