SlideShare a Scribd company logo
1 of 15
Download to read offline
 

AT7
Concurrent Session 
11/14/2013 2:15 PM 
 
 
 

"Test-Driven Development
for Developers:
Plain and Simple"
 
 
 

Presented by:
Rob Myers
Agile Institute
 
 
 
 
 
 
 

Brought to you by: 
 

 
 
340 Corporate Way, Suite 300, Orange Park, FL 32073 
888‐268‐8770 ∙ 904‐278‐0524 ∙ sqeinfo@sqe.com ∙ www.sqe.com
Rob Myers
Agile Institute
Rob Myers is founder of the Agile Institute and a founding member of
the Agile Cooperative. With twenty-seven years of professional experience
on software development teams, Rob has consulted for leading companies
in aerospace, government, medical, software, and financial sectors. He has
been training and coaching organizations in Scrum and Extreme
Programming (XP) management and development practices since 1999.
Rob’s courses—including Essential Test-Driven Development and
Essential Agile Principles and Practices—are a blend of enjoyable,
interactive, hands-on labs plus practical dialog toward preserving sanity in
the workplace. Rob performs short- and long-term coaching to encourage,
solidify, and improve the team's agile practices.
9/10/13	
  

Café
TDD for
Developers:
Plain & Simple
Rob Myers

for
Agile Development Practices
East
14 November 2013

10 September 2013

© Agile Institute 2008-2013

1

10 September 2013

© Agile Institute 2008-2013

2

1	
  
9/10/13	
  

Unit testing
is soooo
DEPRESSING

10 September 2013

© Agile Institute 2008-2013

3

TDD is fun,
and provides
much more than
just unit-tests!

10 September 2013

© Agile Institute 2008-2013

4

2	
  
9/10/13	
  

“The results of the case studies indicate
that the pre-release defect density of the
four products decreased between 40%
and 90% relative to similar projects that
did

not

use

the

TDD

practice.

Subjectively, the teams experienced a
15–35% increase in initial development
time after adopting TDD.”
http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdf, Nagappan et al,
© Springer Science + Business Media, LLC 2008
10 September 2013

© Agile Institute 2008-2013

5

=
10 September 2013

© Agile Institute 2008-2013

6

3	
  
9/10/13	
  

discipline
10 September 2013

© Agile Institute 2008-2013

7

10 September 2013

© Agile Institute 2008-2013

8

4	
  
9/10/13	
  

TDD Demo

10 September 2013

© Agile Institute 2008-2013

9

no magic
import junit.framework.Assert;
import org.junit.Test;
public class SetTests {
@Test
public void setStartsOutEmpty() {
Set mySet = new Set();
Assert.assertEquals(0, mySet.size());
}
}

10 September 2013

© Agile Institute 2008-2013

10

5	
  
9/10/13	
  

requirements & conventions
import junit.framework.Assert;
import org.junit.Test;
public class SetTests {
@Test
public void setStartsOutEmpty() {
Set mySet = new Set();
Assert.assertEquals(0, mySet.size());
}
}
Expected

10 September 2013

Actual

© Agile Institute 2008-2013

11

start simple
To Do
q Empty set.
q Adding an item.
q Adding two different items.
q Adding the same item twice.

10 September 2013

© Agile Institute 2008-2013

12

6	
  
9/10/13	
  

specification, and interface
import junit.framework.Assert;
import org.junit.Test;
public class SetTests {
@Test
public void setStartsOutEmpty() {
Set mySet = new Set();
Assert.assertEquals(0, mySet.size());
}
}

Will not compile. L
10 September 2013

© Agile Institute 2008-2013

13

“Thank you, but…”
package supersets;
public class Set {
public int size() {
throw new RuntimeException("D'oh! Not yet implemented!");
}
}

10 September 2013

© Agile Institute 2008-2013

14

7	
  
9/10/13	
  

“…I want to see it fail successfully”
public class Set {
public int size() {
return -1;
}
}

10 September 2013

© Agile Institute 2008-2013

15

technique: “Fake It”
package supersets;
public class Set {
public int size() {
return 0;
}
}

10 September 2013

© Agile Institute 2008-2013

16

8	
  
9/10/13	
  

a. refactor away duplication
@Test
public void setStartsOutEmpty() {
Set mySet = new Set();
Assert.assertEquals(0, mySet.size());
}

public class Set {
public int size() {
return 0;
}
}

10 September 2013

© Agile Institute 2008-2013

17

b. triangulate

10 September 2013

© Agile Institute 2008-2013

18

9	
  
9/10/13	
  

technique: “Triangulation”
@Test
public void addingItemIncreasesCount() {
Set mySet = new Set();
mySet.add("One item");
Assert.assertEquals(1, mySet.size());
}
@Test
public void setStartsOutEmpty() {
Set mySet = new Set();
Assert.assertEquals(0, mySet.size());
}

10 September 2013

© Agile Institute 2008-2013

19

technique: “Obvious Implementation”
import java.util.ArrayList;
import java.util.List;
public class Set {
private List innerList = new ArrayList();
public int size() {
return innerList.size();
}
public void add(Object element) {
innerList.add(element);
}
}

10 September 2013

© Agile Institute 2008-2013

20

10	
  
9/10/13	
  

maintain (refactor) the tests
Set mySet;
@Before
public void initializeStuffCommonToThisTestClass() {
mySet = new Set();
}
@Test
public void addingItemIncreasesCount() {
mySet.add("One item");
Assert.assertEquals(1, mySet.size());
}
@Test
public void setStartsOutEmpty() {
Assert.assertEquals(0, mySet.size());
}

10 September 2013

© Agile Institute 2008-2013

21

now for something interesting
@Test
public void addingEquivalentItemTwiceAddsItOnlyOnce() {
String theString = "Equivalent string";
mySet.add(theString);
mySet.add(new String(theString));
Assert.assertEquals(1, mySet.size());
}

10 September 2013

© Agile Institute 2008-2013

22

11	
  
9/10/13	
  

the new behavior
public class Set {
private List innerList = new ArrayList();
public int size() {
return innerList.size();
}
public void add(Object element) {
if (!innerList.contains(element))
innerList.add(element);
}
}

10 September 2013

© Agile Institute 2008-2013

23

next?
To Do
q Empty set.
q Adding an item.
q Adding two different items.
q Adding the same item twice.

10 September 2013

© Agile Institute 2008-2013

24

12	
  
9/10/13	
  

1.  Write one unit test.

steps

2.  Build or add to the object under test
until everything compiles.

3.  Red:

Watch the test fail!

4.  Green:

Make all the tests pass by
changing the object under test.

5.  Clean:

Refactor mercilessly!

6.  Repeat.
10 September 2013

© Agile Institute 2008-2013

25

Rob.Myers@agileInstitute.com
http://PowersOfTwo.agileInstitute.com/
@agilecoach

10 September 2013

© Agile Institute 2008-2013

26

13	
  

More Related Content

Viewers also liked

Demystifying the Role of Product Owner
Demystifying the Role of Product OwnerDemystifying the Role of Product Owner
Demystifying the Role of Product OwnerTechWell
 
Key Test Design Techniques
Key Test Design TechniquesKey Test Design Techniques
Key Test Design TechniquesTechWell
 
Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...
Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...
Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...TechWell
 
Testing with an Accent: Internationalization Testing
Testing with an Accent: Internationalization TestingTesting with an Accent: Internationalization Testing
Testing with an Accent: Internationalization TestingTechWell
 
Getting Ready for Your Agile Adventure
Getting Ready for Your Agile AdventureGetting Ready for Your Agile Adventure
Getting Ready for Your Agile AdventureTechWell
 
Leading Change—Even If You’re Not in Charge
Leading Change—Even If You’re Not in ChargeLeading Change—Even If You’re Not in Charge
Leading Change—Even If You’re Not in ChargeTechWell
 
Deadlines Approaching? Budgets Cut? How to Keep Your Sanity
Deadlines Approaching? Budgets Cut? How to Keep Your SanityDeadlines Approaching? Budgets Cut? How to Keep Your Sanity
Deadlines Approaching? Budgets Cut? How to Keep Your SanityTechWell
 
Essential Test Management and Planning
Essential Test Management and PlanningEssential Test Management and Planning
Essential Test Management and PlanningTechWell
 
Collaboration Techniques: Combining New Approaches with Ancient Wisdom
Collaboration Techniques: Combining New Approaches with Ancient WisdomCollaboration Techniques: Combining New Approaches with Ancient Wisdom
Collaboration Techniques: Combining New Approaches with Ancient WisdomTechWell
 
Implementing DevOps and Making It Stick
Implementing DevOps and Making It StickImplementing DevOps and Making It Stick
Implementing DevOps and Making It StickTechWell
 

Viewers also liked (11)

Demystifying the Role of Product Owner
Demystifying the Role of Product OwnerDemystifying the Role of Product Owner
Demystifying the Role of Product Owner
 
Key Test Design Techniques
Key Test Design TechniquesKey Test Design Techniques
Key Test Design Techniques
 
Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...
Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...
Keynote: The Mismeasure of Software: The Last Talk on Measurement You’ll Ever...
 
W7
W7W7
W7
 
Testing with an Accent: Internationalization Testing
Testing with an Accent: Internationalization TestingTesting with an Accent: Internationalization Testing
Testing with an Accent: Internationalization Testing
 
Getting Ready for Your Agile Adventure
Getting Ready for Your Agile AdventureGetting Ready for Your Agile Adventure
Getting Ready for Your Agile Adventure
 
Leading Change—Even If You’re Not in Charge
Leading Change—Even If You’re Not in ChargeLeading Change—Even If You’re Not in Charge
Leading Change—Even If You’re Not in Charge
 
Deadlines Approaching? Budgets Cut? How to Keep Your Sanity
Deadlines Approaching? Budgets Cut? How to Keep Your SanityDeadlines Approaching? Budgets Cut? How to Keep Your Sanity
Deadlines Approaching? Budgets Cut? How to Keep Your Sanity
 
Essential Test Management and Planning
Essential Test Management and PlanningEssential Test Management and Planning
Essential Test Management and Planning
 
Collaboration Techniques: Combining New Approaches with Ancient Wisdom
Collaboration Techniques: Combining New Approaches with Ancient WisdomCollaboration Techniques: Combining New Approaches with Ancient Wisdom
Collaboration Techniques: Combining New Approaches with Ancient Wisdom
 
Implementing DevOps and Making It Stick
Implementing DevOps and Making It StickImplementing DevOps and Making It Stick
Implementing DevOps and Making It Stick
 

Similar to Test-Driven Development for Developers: Plain and Simple

Alien driven-development
Alien driven-developmentAlien driven-development
Alien driven-developmentMarkus Eisele
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?Robert Munteanu
 
Test Automation on Large Agile Projects: It's Not a Cakewalk
Test Automation on Large Agile Projects: It's Not a CakewalkTest Automation on Large Agile Projects: It's Not a Cakewalk
Test Automation on Large Agile Projects: It's Not a CakewalkTechWell
 
Hands On with Selenium and WebDriver
Hands On with Selenium and WebDriverHands On with Selenium and WebDriver
Hands On with Selenium and WebDriverTechWell
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example usingIevgenii Katsan
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
The Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and More
The Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and MoreThe Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and More
The Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and MoreTechWell
 
Developer Test - Things to Know
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Knowvilniusjug
 
iOS Development Methodology
iOS Development MethodologyiOS Development Methodology
iOS Development MethodologySmartLogic
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-appsVenkata Ramana
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxKnoldus Inc.
 
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonUnit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonbeITconference
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...TEST Huddle
 
Testing with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifeTesting with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifePeter Gfader
 
Developer Tests - Things to Know
Developer Tests - Things to KnowDeveloper Tests - Things to Know
Developer Tests - Things to KnowVaidas Pilkauskas
 
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...University of Antwerp
 

Similar to Test-Driven Development for Developers: Plain and Simple (20)

Alien driven-development
Alien driven-developmentAlien driven-development
Alien driven-development
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?
 
Test Automation on Large Agile Projects: It's Not a Cakewalk
Test Automation on Large Agile Projects: It's Not a CakewalkTest Automation on Large Agile Projects: It's Not a Cakewalk
Test Automation on Large Agile Projects: It's Not a Cakewalk
 
Hands On with Selenium and WebDriver
Hands On with Selenium and WebDriverHands On with Selenium and WebDriver
Hands On with Selenium and WebDriver
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example using
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
The Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and More
The Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and MoreThe Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and More
The Challenges of BIG Testing: Automation, Virtualization, Outsourcing, and More
 
Grails Advanced
Grails Advanced Grails Advanced
Grails Advanced
 
Developer Test - Things to Know
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Know
 
iOS Development Methodology
iOS Development MethodologyiOS Development Methodology
iOS Development Methodology
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptx
 
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, MelonUnit & Automation Testing in Android - Stanislav Gatsev, Melon
Unit & Automation Testing in Android - Stanislav Gatsev, Melon
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
 
Testing with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs LifeTesting with VS2010 - A Bugs Life
Testing with VS2010 - A Bugs Life
 
Developer Tests - Things to Know
Developer Tests - Things to KnowDeveloper Tests - Things to Know
Developer Tests - Things to Know
 
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
 
Open stack qa and tempest
Open stack qa and tempestOpen stack qa and tempest
Open stack qa and tempest
 

More from TechWell

Failing and Recovering
Failing and RecoveringFailing and Recovering
Failing and RecoveringTechWell
 
Instill a DevOps Testing Culture in Your Team and Organization
Instill a DevOps Testing Culture in Your Team and Organization Instill a DevOps Testing Culture in Your Team and Organization
Instill a DevOps Testing Culture in Your Team and Organization TechWell
 
Test Design for Fully Automated Build Architecture
Test Design for Fully Automated Build ArchitectureTest Design for Fully Automated Build Architecture
Test Design for Fully Automated Build ArchitectureTechWell
 
System-Level Test Automation: Ensuring a Good Start
System-Level Test Automation: Ensuring a Good StartSystem-Level Test Automation: Ensuring a Good Start
System-Level Test Automation: Ensuring a Good StartTechWell
 
Build Your Mobile App Quality and Test Strategy
Build Your Mobile App Quality and Test StrategyBuild Your Mobile App Quality and Test Strategy
Build Your Mobile App Quality and Test StrategyTechWell
 
Testing Transformation: The Art and Science for Success
Testing Transformation: The Art and Science for SuccessTesting Transformation: The Art and Science for Success
Testing Transformation: The Art and Science for SuccessTechWell
 
Implement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlowImplement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlowTechWell
 
Develop WebDriver Automated Tests—and Keep Your Sanity
Develop WebDriver Automated Tests—and Keep Your SanityDevelop WebDriver Automated Tests—and Keep Your Sanity
Develop WebDriver Automated Tests—and Keep Your SanityTechWell
 
Eliminate Cloud Waste with a Holistic DevOps Strategy
Eliminate Cloud Waste with a Holistic DevOps StrategyEliminate Cloud Waste with a Holistic DevOps Strategy
Eliminate Cloud Waste with a Holistic DevOps StrategyTechWell
 
Transform Test Organizations for the New World of DevOps
Transform Test Organizations for the New World of DevOpsTransform Test Organizations for the New World of DevOps
Transform Test Organizations for the New World of DevOpsTechWell
 
The Fourth Constraint in Project Delivery—Leadership
The Fourth Constraint in Project Delivery—LeadershipThe Fourth Constraint in Project Delivery—Leadership
The Fourth Constraint in Project Delivery—LeadershipTechWell
 
Resolve the Contradiction of Specialists within Agile Teams
Resolve the Contradiction of Specialists within Agile TeamsResolve the Contradiction of Specialists within Agile Teams
Resolve the Contradiction of Specialists within Agile TeamsTechWell
 
Pin the Tail on the Metric: A Field-Tested Agile Game
Pin the Tail on the Metric: A Field-Tested Agile GamePin the Tail on the Metric: A Field-Tested Agile Game
Pin the Tail on the Metric: A Field-Tested Agile GameTechWell
 
Agile Performance Holarchy (APH)—A Model for Scaling Agile Teams
Agile Performance Holarchy (APH)—A Model for Scaling Agile TeamsAgile Performance Holarchy (APH)—A Model for Scaling Agile Teams
Agile Performance Holarchy (APH)—A Model for Scaling Agile TeamsTechWell
 
A Business-First Approach to DevOps Implementation
A Business-First Approach to DevOps ImplementationA Business-First Approach to DevOps Implementation
A Business-First Approach to DevOps ImplementationTechWell
 
Databases in a Continuous Integration/Delivery Process
Databases in a Continuous Integration/Delivery ProcessDatabases in a Continuous Integration/Delivery Process
Databases in a Continuous Integration/Delivery ProcessTechWell
 
Mobile Testing: What—and What Not—to Automate
Mobile Testing: What—and What Not—to AutomateMobile Testing: What—and What Not—to Automate
Mobile Testing: What—and What Not—to AutomateTechWell
 
Cultural Intelligence: A Key Skill for Success
Cultural Intelligence: A Key Skill for SuccessCultural Intelligence: A Key Skill for Success
Cultural Intelligence: A Key Skill for SuccessTechWell
 
Turn the Lights On: A Power Utility Company's Agile Transformation
Turn the Lights On: A Power Utility Company's Agile TransformationTurn the Lights On: A Power Utility Company's Agile Transformation
Turn the Lights On: A Power Utility Company's Agile TransformationTechWell
 

More from TechWell (20)

Failing and Recovering
Failing and RecoveringFailing and Recovering
Failing and Recovering
 
Instill a DevOps Testing Culture in Your Team and Organization
Instill a DevOps Testing Culture in Your Team and Organization Instill a DevOps Testing Culture in Your Team and Organization
Instill a DevOps Testing Culture in Your Team and Organization
 
Test Design for Fully Automated Build Architecture
Test Design for Fully Automated Build ArchitectureTest Design for Fully Automated Build Architecture
Test Design for Fully Automated Build Architecture
 
System-Level Test Automation: Ensuring a Good Start
System-Level Test Automation: Ensuring a Good StartSystem-Level Test Automation: Ensuring a Good Start
System-Level Test Automation: Ensuring a Good Start
 
Build Your Mobile App Quality and Test Strategy
Build Your Mobile App Quality and Test StrategyBuild Your Mobile App Quality and Test Strategy
Build Your Mobile App Quality and Test Strategy
 
Testing Transformation: The Art and Science for Success
Testing Transformation: The Art and Science for SuccessTesting Transformation: The Art and Science for Success
Testing Transformation: The Art and Science for Success
 
Implement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlowImplement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlow
 
Develop WebDriver Automated Tests—and Keep Your Sanity
Develop WebDriver Automated Tests—and Keep Your SanityDevelop WebDriver Automated Tests—and Keep Your Sanity
Develop WebDriver Automated Tests—and Keep Your Sanity
 
Ma 15
Ma 15Ma 15
Ma 15
 
Eliminate Cloud Waste with a Holistic DevOps Strategy
Eliminate Cloud Waste with a Holistic DevOps StrategyEliminate Cloud Waste with a Holistic DevOps Strategy
Eliminate Cloud Waste with a Holistic DevOps Strategy
 
Transform Test Organizations for the New World of DevOps
Transform Test Organizations for the New World of DevOpsTransform Test Organizations for the New World of DevOps
Transform Test Organizations for the New World of DevOps
 
The Fourth Constraint in Project Delivery—Leadership
The Fourth Constraint in Project Delivery—LeadershipThe Fourth Constraint in Project Delivery—Leadership
The Fourth Constraint in Project Delivery—Leadership
 
Resolve the Contradiction of Specialists within Agile Teams
Resolve the Contradiction of Specialists within Agile TeamsResolve the Contradiction of Specialists within Agile Teams
Resolve the Contradiction of Specialists within Agile Teams
 
Pin the Tail on the Metric: A Field-Tested Agile Game
Pin the Tail on the Metric: A Field-Tested Agile GamePin the Tail on the Metric: A Field-Tested Agile Game
Pin the Tail on the Metric: A Field-Tested Agile Game
 
Agile Performance Holarchy (APH)—A Model for Scaling Agile Teams
Agile Performance Holarchy (APH)—A Model for Scaling Agile TeamsAgile Performance Holarchy (APH)—A Model for Scaling Agile Teams
Agile Performance Holarchy (APH)—A Model for Scaling Agile Teams
 
A Business-First Approach to DevOps Implementation
A Business-First Approach to DevOps ImplementationA Business-First Approach to DevOps Implementation
A Business-First Approach to DevOps Implementation
 
Databases in a Continuous Integration/Delivery Process
Databases in a Continuous Integration/Delivery ProcessDatabases in a Continuous Integration/Delivery Process
Databases in a Continuous Integration/Delivery Process
 
Mobile Testing: What—and What Not—to Automate
Mobile Testing: What—and What Not—to AutomateMobile Testing: What—and What Not—to Automate
Mobile Testing: What—and What Not—to Automate
 
Cultural Intelligence: A Key Skill for Success
Cultural Intelligence: A Key Skill for SuccessCultural Intelligence: A Key Skill for Success
Cultural Intelligence: A Key Skill for Success
 
Turn the Lights On: A Power Utility Company's Agile Transformation
Turn the Lights On: A Power Utility Company's Agile TransformationTurn the Lights On: A Power Utility Company's Agile Transformation
Turn the Lights On: A Power Utility Company's Agile Transformation
 

Recently uploaded

Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKUXDXConf
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 

Recently uploaded (20)

Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 

Test-Driven Development for Developers: Plain and Simple

  • 1.   AT7 Concurrent Session  11/14/2013 2:15 PM        "Test-Driven Development for Developers: Plain and Simple"       Presented by: Rob Myers Agile Institute               Brought to you by:        340 Corporate Way, Suite 300, Orange Park, FL 32073  888‐268‐8770 ∙ 904‐278‐0524 ∙ sqeinfo@sqe.com ∙ www.sqe.com
  • 2. Rob Myers Agile Institute Rob Myers is founder of the Agile Institute and a founding member of the Agile Cooperative. With twenty-seven years of professional experience on software development teams, Rob has consulted for leading companies in aerospace, government, medical, software, and financial sectors. He has been training and coaching organizations in Scrum and Extreme Programming (XP) management and development practices since 1999. Rob’s courses—including Essential Test-Driven Development and Essential Agile Principles and Practices—are a blend of enjoyable, interactive, hands-on labs plus practical dialog toward preserving sanity in the workplace. Rob performs short- and long-term coaching to encourage, solidify, and improve the team's agile practices.
  • 3. 9/10/13   Café TDD for Developers: Plain & Simple Rob Myers for Agile Development Practices East 14 November 2013 10 September 2013 © Agile Institute 2008-2013 1 10 September 2013 © Agile Institute 2008-2013 2 1  
  • 4. 9/10/13   Unit testing is soooo DEPRESSING 10 September 2013 © Agile Institute 2008-2013 3 TDD is fun, and provides much more than just unit-tests! 10 September 2013 © Agile Institute 2008-2013 4 2  
  • 5. 9/10/13   “The results of the case studies indicate that the pre-release defect density of the four products decreased between 40% and 90% relative to similar projects that did not use the TDD practice. Subjectively, the teams experienced a 15–35% increase in initial development time after adopting TDD.” http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdf, Nagappan et al, © Springer Science + Business Media, LLC 2008 10 September 2013 © Agile Institute 2008-2013 5 = 10 September 2013 © Agile Institute 2008-2013 6 3  
  • 6. 9/10/13   discipline 10 September 2013 © Agile Institute 2008-2013 7 10 September 2013 © Agile Institute 2008-2013 8 4  
  • 7. 9/10/13   TDD Demo 10 September 2013 © Agile Institute 2008-2013 9 no magic import junit.framework.Assert; import org.junit.Test; public class SetTests { @Test public void setStartsOutEmpty() { Set mySet = new Set(); Assert.assertEquals(0, mySet.size()); } } 10 September 2013 © Agile Institute 2008-2013 10 5  
  • 8. 9/10/13   requirements & conventions import junit.framework.Assert; import org.junit.Test; public class SetTests { @Test public void setStartsOutEmpty() { Set mySet = new Set(); Assert.assertEquals(0, mySet.size()); } } Expected 10 September 2013 Actual © Agile Institute 2008-2013 11 start simple To Do q Empty set. q Adding an item. q Adding two different items. q Adding the same item twice. 10 September 2013 © Agile Institute 2008-2013 12 6  
  • 9. 9/10/13   specification, and interface import junit.framework.Assert; import org.junit.Test; public class SetTests { @Test public void setStartsOutEmpty() { Set mySet = new Set(); Assert.assertEquals(0, mySet.size()); } } Will not compile. L 10 September 2013 © Agile Institute 2008-2013 13 “Thank you, but…” package supersets; public class Set { public int size() { throw new RuntimeException("D'oh! Not yet implemented!"); } } 10 September 2013 © Agile Institute 2008-2013 14 7  
  • 10. 9/10/13   “…I want to see it fail successfully” public class Set { public int size() { return -1; } } 10 September 2013 © Agile Institute 2008-2013 15 technique: “Fake It” package supersets; public class Set { public int size() { return 0; } } 10 September 2013 © Agile Institute 2008-2013 16 8  
  • 11. 9/10/13   a. refactor away duplication @Test public void setStartsOutEmpty() { Set mySet = new Set(); Assert.assertEquals(0, mySet.size()); } public class Set { public int size() { return 0; } } 10 September 2013 © Agile Institute 2008-2013 17 b. triangulate 10 September 2013 © Agile Institute 2008-2013 18 9  
  • 12. 9/10/13   technique: “Triangulation” @Test public void addingItemIncreasesCount() { Set mySet = new Set(); mySet.add("One item"); Assert.assertEquals(1, mySet.size()); } @Test public void setStartsOutEmpty() { Set mySet = new Set(); Assert.assertEquals(0, mySet.size()); } 10 September 2013 © Agile Institute 2008-2013 19 technique: “Obvious Implementation” import java.util.ArrayList; import java.util.List; public class Set { private List innerList = new ArrayList(); public int size() { return innerList.size(); } public void add(Object element) { innerList.add(element); } } 10 September 2013 © Agile Institute 2008-2013 20 10  
  • 13. 9/10/13   maintain (refactor) the tests Set mySet; @Before public void initializeStuffCommonToThisTestClass() { mySet = new Set(); } @Test public void addingItemIncreasesCount() { mySet.add("One item"); Assert.assertEquals(1, mySet.size()); } @Test public void setStartsOutEmpty() { Assert.assertEquals(0, mySet.size()); } 10 September 2013 © Agile Institute 2008-2013 21 now for something interesting @Test public void addingEquivalentItemTwiceAddsItOnlyOnce() { String theString = "Equivalent string"; mySet.add(theString); mySet.add(new String(theString)); Assert.assertEquals(1, mySet.size()); } 10 September 2013 © Agile Institute 2008-2013 22 11  
  • 14. 9/10/13   the new behavior public class Set { private List innerList = new ArrayList(); public int size() { return innerList.size(); } public void add(Object element) { if (!innerList.contains(element)) innerList.add(element); } } 10 September 2013 © Agile Institute 2008-2013 23 next? To Do q Empty set. q Adding an item. q Adding two different items. q Adding the same item twice. 10 September 2013 © Agile Institute 2008-2013 24 12  
  • 15. 9/10/13   1.  Write one unit test. steps 2.  Build or add to the object under test until everything compiles. 3.  Red: Watch the test fail! 4.  Green: Make all the tests pass by changing the object under test. 5.  Clean: Refactor mercilessly! 6.  Repeat. 10 September 2013 © Agile Institute 2008-2013 25 Rob.Myers@agileInstitute.com http://PowersOfTwo.agileInstitute.com/ @agilecoach 10 September 2013 © Agile Institute 2008-2013 26 13