SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
Pragmatic
Test Driven Development
Sunday, January 22, 12
Your Host
Clayton
Lengel-Zigich
clayton@integrumtech.com
Certified Scrum Master
Certified Scrum Product Owner
Certified Scrum Professional
@claytonlz
Sunday, January 22, 12
Types of Testing
Sunday, January 22, 12
Types of Testing
Acceptance
Integration
Unit
Sunday, January 22, 12
Types of Testing
POÄNG
This piece should be 24”
These third-party rubber feet
should fit
Given all of these pieces,
I can sit in the chair
Sunday, January 22, 12
Types of Testing
Acceptance
Unit Unit Unit
Unit Unit Unit
Acceptance
Sunday, January 22, 12
Types of Testing
Feature
Unit Unit Unit
Acceptance
Feature
Unit Unit Unit
Acceptance
Feature
Unit Unit Unit
Acceptance
Feature
Unit Unit Unit
Acceptance
Feature
Unit Unit Unit
Acceptance
Feature
Unit Unit Unit
Acceptance
Sunday, January 22, 12
Who’s Responsible?
Sunday, January 22, 12
Who’s Responsible?
QA
QA QA QA QA QA QA QA
QA QA QA QA QA QA QA
QA QA QA QA QA QA QA
QA QA QA QA QA QA QA
QA QA QA QA QA QA QA
QA QA QA QA QA QA QA
Sunday, January 22, 12
Who’s Responsible?
QA
Sunday, January 22, 12
Who Writes Unit Tests?
Sunday, January 22, 12
Who Writes Acceptance Tests?
DEV
CUSTOMER
QA
Discovery
Sunday, January 22, 12
Automated Testing
Sunday, January 22, 12
Continuous Integration
Continuous integration avoids or detects compatibility
problems early ... if you integrate throughout the project
in small amounts you will not find your self trying to
integrate the system for weeks at the project's end while
the deadline slips by.
Always work in the context of the latest version of the
system.
Sunday, January 22, 12
Continuous Integration
Build
Server
SCM
SCM
Sunday, January 22, 12
Continuous Integration
Build
Server
Compilation
Executes Tests
Defines Status
Sunday, January 22, 12
Continuous Integration
10
MINUTE BUILD
Sunday, January 22, 12
Test First Programming
Sunday, January 22, 12
Test First Programming
Sunday, January 22, 12
Test Driven Development
Sunday, January 22, 12
Test Driven Development
Test
Code
Test
Sunday, January 22, 12
Test Driven Development
Failing
Passing
Refactored
Sunday, January 22, 12
Test Driven Development
Failing
Acceptance Test
Failing
Unit Test
Passing
Unit Test
Refactor
Sunday, January 22, 12
Test Driven Development
Code Code Code Code Test Code Code
Time
Code
Test
Time
Code
Test Code
Test Test
Sunday, January 22, 12
Frameworks and Tools
Sunday, January 22, 12
Frameworks And Tools
xUnit
Sunday, January 22, 12
Frameworks And Tools
xUnit Language
JUnit Java
NUnit .Net
TestUnit Ruby
QUnit JavaScript
PhpUnit PHP
Sunday, January 22, 12
Pair Programming
Sunday, January 22, 12
Pair Programming
Write Test Write Code
Sunday, January 22, 12
Tutorial #1
Sunday, January 22, 12
Test Unit Fundamentals
test_strike_strike_ball_ball_ball
test_full_count
vs
Sunday, January 22, 12
Test Unit Fundamentals
Setup
Assertion
Assertion
Assertion
Tear Down
Sunday, January 22, 12
Test Unit Fundamentals
assert(test, msg = (nomsg = true; nil))
assert_equal(exp, act, msg = nil)
assert_no_match(regexp, string, msg=nil)
assert_not_equal(exp, act, msg=nil)
assert_not_nil(exp, msg=nil)
assert_not_same(expected, actual, message="")
assert_nothing_raised(*args)
assert_nothing_thrown(msg=nil)
assert_raise(*args, &b)
assert_respond_to(obj, meth, msg = nil)
Sunday, January 22, 12
TDD RUles
1.Only write code that makes a test pass
2.Only write enough of a test to make it fail
3.Only write enough code to make a test pass
Sunday, January 22, 12
Tutorial #1
In pairs, write a program that can play the game of
hangman.
50m
Activity Time
Sunday, January 22, 12
Mocking & STUBBING
Mocks vs. Stubs
Indirect Outputs vs. Indirect Inputs
Objects vs. Methods
Behavior vs. State
Sunday, January 22, 12
Mocking
Order
Warehouse
?
?
?
Warehouse
Sunday, January 22, 12
Mocking
Order
Warehouse
WarehouseItem
order.items.each do |item|
warehouse_item = Warehouse.find(item)
warehouse_item.stock_reservation.reserve
end
StockReservation
Sunday, January 22, 12
Mocking
Order
Warehouse
Warehouse.reserve(items)
Sunday, January 22, 12
Mocking
fake_warehouse = mock(Warehouse)
assert(
fake_warehouse.received("reserve")
.with(items),
"Expected the warehouse to check its stock"
)
Sunday, January 22, 12
STUBBING
CUSTOMER
“If any items are out-of-stock,
the system should prevent the
order from completing”
Sunday, January 22, 12
STUBBING
def test_out_of_stock
order = Order.new
item1 = Item.new(:sku => "abc")
item2 = Item.new(:sku => "def")
order.items = [item1, item2]
stock_item1 = StockItem.new(:sku => 'zyx')
...
end
Sunday, January 22, 12
STUBBING
def test_invalid_items
Warehouse.stub(:reserve)
.and_raise(OutOfStockException)
assert_raise(OutOfStockException) do
order.complete
end
end
Sunday, January 22, 12
Tutorial #2
Sunday, January 22, 12
Tutorial #2
In pairs, write a program that implements Conway’s
game of life.
45m
Activity Time
Sunday, January 22, 12
Game of Life
“The universe of the Game of Life is an infinite two-
dimensional orthogonal grid of square cells, each of which
is in one of two possible states, alive or dead. Every cell
interacts with its eight neighbors, which are the cells that
are horizontally, vertically, or diagonally adjacent. At each
step in time, the following transitions occur:”
Sunday, January 22, 12
Game of Life: Rules
1
Any live cell with fewer than two live neighbors dies,
as if caused by under-population.
2
Any live cell with two or three live neighbors lives on
to the next generation.
3 Any live cell with more than three live neighbors dies,
as if by overcrowding.
Any dead cell with exactly three live neighbors
becomes a live cell, as if by reproduction.
4
Sunday, January 22, 12
Closing
Sunday, January 22, 12
Test Feedback
Listen to your tests
Sunday, January 22, 12
Code Coverage
DEV
MANAGEMENT
“If we’re not at 90% code
coverage you’re all working
on Saturday.”
“assert(true)”
Sunday, January 22, 12
Continuously Integrate
Live and Die
by the build
Sunday, January 22, 12
Plan to Succeed
Write tests before you plan
the implementation
BDD
Failing
Unit Test
Passing
Unit Test
Refactor
TDD
Sunday, January 22, 12

Contenu connexe

Similaire à Pragmatic Test Driven Development

Test tutorial
Test tutorialTest tutorial
Test tutorialmsksaba
 
Supporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent ReasoningSupporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent ReasoningNeil Ernst
 
Testing without assertions - #HUSTEF2019
Testing without assertions - #HUSTEF2019Testing without assertions - #HUSTEF2019
Testing without assertions - #HUSTEF2019SAP SE
 
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecampIasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecampCodecamp Romania
 
Better code through making bugs
Better code through making bugsBetter code through making bugs
Better code through making bugsSeb Rose
 
Eclipse Democamp Zurich
Eclipse Democamp ZurichEclipse Democamp Zurich
Eclipse Democamp ZurichMarcel Bruch
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)Steve Upton
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkPeter Kofler
 
SfCon: Test Driven Development
SfCon: Test Driven DevelopmentSfCon: Test Driven Development
SfCon: Test Driven DevelopmentAugusto Pascutti
 
PuppetConf 2015 - Testing - Richard Pijnenburg
PuppetConf 2015 - Testing - Richard PijnenburgPuppetConf 2015 - Testing - Richard Pijnenburg
PuppetConf 2015 - Testing - Richard PijnenburgRichard Pijnenburg
 

Similaire à Pragmatic Test Driven Development (13)

Test tutorial
Test tutorialTest tutorial
Test tutorial
 
Supporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent ReasoningSupporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent Reasoning
 
Testing without assertions - #HUSTEF2019
Testing without assertions - #HUSTEF2019Testing without assertions - #HUSTEF2019
Testing without assertions - #HUSTEF2019
 
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecampIasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
 
Better code through making bugs
Better code through making bugsBetter code through making bugs
Better code through making bugs
 
Eclipse Democamp Zurich
Eclipse Democamp ZurichEclipse Democamp Zurich
Eclipse Democamp Zurich
 
Continous delivery
Continous deliveryContinous delivery
Continous delivery
 
Test-Tutorial
Test-TutorialTest-Tutorial
Test-Tutorial
 
Test-Tutorial
Test-TutorialTest-Tutorial
Test-Tutorial
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
SfCon: Test Driven Development
SfCon: Test Driven DevelopmentSfCon: Test Driven Development
SfCon: Test Driven Development
 
PuppetConf 2015 - Testing - Richard Pijnenburg
PuppetConf 2015 - Testing - Richard PijnenburgPuppetConf 2015 - Testing - Richard Pijnenburg
PuppetConf 2015 - Testing - Richard Pijnenburg
 

Dernier

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Pragmatic Test Driven Development