SlideShare a Scribd company logo
Agile Work Quality:
TDD and Unit Tests
Keith Callis
Principle Consultant, Strategic Data Systems
Keith.Callis@sds.io
About Keith Callis
Principal Consultant at SDS, Inc., based in Cincinnati.
 Software developer.
 Scrum Master (Scrum Alliance).
Current agile projects:
 (Pivotal Tracker) SQL Server conversions.
 (Rally) Hadoop, Oracle, MongoDB, Java, Scala.
When not writing or breaking software, he is amateur
photographer or chef in his kitchen.
Strategic Data Systems – What we do:
We work with our customers to improve their business with technology.
Our professional services include:
Application Development and Application Renovations
Architecture, Development, and Architectural Design Reviews
.NET, Java
Agility - Agile Coaching and Transformations
Training - Agile, .NET
Our place or yours!
We are looking for .NET/Java developers,
Scrum Masters and Product Owners.
Agile Work Flow
• Epics
• Features
• Stories
• Stories only
• Backlog of stories
Epics
• Work goal
• Create Payroll system
• New Web site for maintaining customer information
• Add searching capability to existing web site
Features
• Break down of an epic
• Payroll system
• Maintain staff
• Add/Inactivate people
• Change pay
• Change deductions
• Calculate payroll
• Grose Pay
• Deductions
• Net Pay
• Make payments
• Paper checks
• Direct deposit
Stories
• Break down a feature
• Calculate payroll
• Gross pay
• Hourly
• Salaried
• Overtime
• Bonuses
• Deductions
• Pre-tax items
• 401K
• Insurance
• HSA
• Taxes
• Federal
• State
• Local
• SSN
Work a story
• Description of the work
• Ask for more information is not clear
• Clear Condition of Acceptance for story
• Ask for clarification if not clear or not known how to deliver
• Attachments to story that may help
• Spreadsheets with existing calculations
Time to Start Coding?
• Should code “design” take place?
• What code should be added?
• Where should the code be added?
• How to meet “conditions of acceptance” in story?
• How to test new code?
• Are there existing tests?
TDD
• Write a Test
• Run the Test
• Test should Fail
• Write just enough code for Test to pass
• Run the Test
• Test should Pass
• Repeat
Write Test First
@Test
public void whenMonthly_thenReturnOneTwelfth() {
Double yearlySalary = 12000.0;
Double expected = 1000.00;
Double actual =
salaryCalculation.CalculateMonthlySalary(yearlySalary)
;
Assert.assertEquals("Expected Monthly Salary not
correct", expected, actual);
}
Pure TDD
• Missed first test
• Should have a test that the class exists
• Then go with the test for the method
Test Values
@Test
public void whenMonthly_thenReturnOneTwelfthRounded() {
Double yearlySalary = 12002.0;
Double expected =1000.17;
Double actual =
salaryCalculation.CalculateMonthlySalary(yearlySalary);
Assert.assertEquals("Expected Monthly Salary not
correct", expected, actual);
}
java.lang.AssertionError: Expected Monthly Salary not correct
Expected :1000.17
Actual :1000.1666666666666
Code Change
public double CalculateMonthlySalary(double
annualSalary) {
return annualSalary / 12;
}
______________________________________________
public double CalculateMonthlySalary(double
annualSalary) {
return Math.round(100.0 * annualSalary / 12)
/ 100.0;
}
Edit Code Again
public SalaryCalculationImpl(double salary,
double periods) {
this.annualSalary = salary;
this.periods = periods;
}
public void CalculateMonthlySalary() {
this.salary = Math.round(100.0 *
annualSalary / periods) / 100.0;
}
Test Passes, Wrong Check
@Test
public void whenMonthly_thenReturnOneTwelfth() {
Double yearlySalary = 12000.0;
Double expected = 1000.00;
salaryCalculation = new
SalaryCalculationImpl(yearlySalary, 12);
salaryCalculation.CalculateMonthlySalary();
Assert.assertNotNull("SalaryCalculation
object not null", salaryCalculation);
}
Test Passes, Better Check
@Test
public void whenMonthly_thenReturnOneTwelfth() {
Double yearlySalary = 12000.0;
Double expected = 1000.00;
salaryCalculation = new
SalaryCalculationImpl(yearlySalary, 12);
salaryCalculation.CalculateMonthlySalary();
Assert.assertEquals("Expected Monthly Salary
not correct", expected,
salaryCalculation.getSalary(), 0);
}
TDD Drive Code Design
• As tests are written
• Minimal code gets written
• No extra/dead code gets written
• New code added to pass new tests
• Lowers chance for code that cannot be tested
No TDD, but Unit Tests
• Write a little new code
• Method
• Class
• Write tests for new code
• Runs risk of not testing all paths of code
Agile Work Quality:  Test Driven Development and Unit Tests
Code First, Test Later
• Write most of program first
• Try to write unit tests
• Takes more time
• Some code may not be able to be tested
• Can result in less code coverage
Write Code, Toss Over the Wall
• Write program
• No tests
• Let someone else test
• QA tester
• Not all paths tested
• If test fails, harder to locate failing code
Unit vs Integration Tests
• Unit test
• Just code (class/method, maybe multiple classes)
• No external resources (database, file)
• Integration test
• Code accessing external resources (database, file)
• Harder to setup
• Harder to validate results
Many Unit Tests
• Allows more confidence when making changes to code
• Example for new story for a found defect
• Create new unit tests that fail
• Update code for new unit tests to pass
• Run ALL unit test to insure no impact on other areas of code
“Eat the dog food”
• All unit tests pass for programs
• However, issue when programs used in final system
• Web site
• Production data
• Program being called by other programs
Handle Multiple Conditions
• Example handling batches, e.g. batch size 100
• Unit test passes using value of 100
• Unit test fails using value of above or below 100
• Remember to handle multiple values with multiple unit tests
• Zero
• One
• More than one
• Null
• Negative
Tests and Story’s COA
• Depending on PO and COA and Story
• One or two unit tests may allow story to be accepted
• An integration test may allow story to be accepted
Story’s COA and Tests
• Unit tests can be written for well written COA’s
• This can drive out more details for story
• More COA’s may be needed for found conditions
• Original COA’s handled “good path”
• Unit tests points out “invalid paths”
Agile Work Quality:  Test Driven Development and Unit Tests
Test Early, Test Often
image from https://brockbiv.wordpress.com
Questions?
¿
Keith.Callis@sds.io

More Related Content

What's hot (20)

PPTX
Site speed Server Optimization
Shelly Fagin
 
PDF
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Thoughtworks
 
PPTX
Parallel run selenium tests in a good way
COMAQA.BY
 
PPT
High Availability Perl DBI + MySQL
Steve Purkis
 
PDF
DSR Testing (Part 2)
Steve Upton
 
PPTX
The agile elephant in the room
AgileDenver
 
PPTX
Dentrix Upgrade Presentation
Kevin Jones
 
PDF
Automate across Platform, OS, Technologies with TaaS
Anand Bagmar
 
PDF
Big Retail Goes Reactive at Walmart
Nurun
 
PPTX
Effective Java applications
Strannik_2013
 
PPTX
Setting Up CircleCI Workflows for Your Salesforce Apps
Daniel Stange
 
PPTX
Improving the Quality of Existing Software
Steven Smith
 
PDF
[@IndeedEng] Redundant Array of Inexpensive Datacenters
indeedeng
 
PDF
JIRA Performance After 300,000 Issues
Atlassian
 
PPTX
Managing Data in Microservices
Randy Shoup
 
PDF
Managing Large Numbers of Non trivial ETL pipelines.
Jessica Flanagan
 
PPTX
Automation and Developer Infrastructure — Empowering Engineers to Move from I...
indeedeng
 
PDF
[@IndeedEng] Boxcar: A self-balancing distributed services protocol
indeedeng
 
PDF
Strategies to edit production data
Software Guru
 
PDF
Building and Supporting Billion Dollar Ships with JIRA - Greg Warner
Atlassian
 
Site speed Server Optimization
Shelly Fagin
 
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Thoughtworks
 
Parallel run selenium tests in a good way
COMAQA.BY
 
High Availability Perl DBI + MySQL
Steve Purkis
 
DSR Testing (Part 2)
Steve Upton
 
The agile elephant in the room
AgileDenver
 
Dentrix Upgrade Presentation
Kevin Jones
 
Automate across Platform, OS, Technologies with TaaS
Anand Bagmar
 
Big Retail Goes Reactive at Walmart
Nurun
 
Effective Java applications
Strannik_2013
 
Setting Up CircleCI Workflows for Your Salesforce Apps
Daniel Stange
 
Improving the Quality of Existing Software
Steven Smith
 
[@IndeedEng] Redundant Array of Inexpensive Datacenters
indeedeng
 
JIRA Performance After 300,000 Issues
Atlassian
 
Managing Data in Microservices
Randy Shoup
 
Managing Large Numbers of Non trivial ETL pipelines.
Jessica Flanagan
 
Automation and Developer Infrastructure — Empowering Engineers to Move from I...
indeedeng
 
[@IndeedEng] Boxcar: A self-balancing distributed services protocol
indeedeng
 
Strategies to edit production data
Software Guru
 
Building and Supporting Billion Dollar Ships with JIRA - Greg Warner
Atlassian
 

Similar to Agile Work Quality: Test Driven Development and Unit Tests (20)

PPTX
Get Testing with tSQLt - SQL In The City Workshop 2014
Red Gate Software
 
PDF
Sledgehammer to Fine Brush for QA
Shelley Lambert
 
PDF
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
.NET Conf UY
 
PPTX
VT.NET 20160411: An Intro to Test Driven Development (TDD)
Rob Hale
 
PPTX
Load testing with Visual Studio and Azure - Andrew Siemer
Andrew Siemer
 
PPTX
Road to Continuous Delivery - Wix.com
Aviran Mordo
 
PPTX
Practicing Red, Green, Refactor!
XPDays
 
PDF
CBDW2014 - Behavior Driven Development with TestBox
Ortus Solutions, Corp
 
PDF
Testing Tools Online Training.pdf
SpiritsoftsTraining
 
PDF
Bigger Unit Test Are Better
Peter Schuler
 
PDF
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Dinis Cruz
 
PPTX
Testing the Untestable
Mark Baker
 
PDF
Agile testing
Raj Indugula
 
PPTX
Improving the Quality of Existing Software - DevIntersection April 2016
Steven Smith
 
PPTX
Improving the Quality of Existing Software
Steven Smith
 
PDF
How to Automate your Enterprise Application / ERP Testing
RTTS
 
PDF
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
AgileNetwork
 
PDF
SledgehammerToFinebrush_Devnexus_2021
Shelley Lambert
 
PPTX
Westrich spock-assets-gum
Brian Westrich
 
PPTX
Software Testing_A_mmmmmmmmmmmmmmmmmmmmm
IwannatelluAstorylas
 
Get Testing with tSQLt - SQL In The City Workshop 2014
Red Gate Software
 
Sledgehammer to Fine Brush for QA
Shelley Lambert
 
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
.NET Conf UY
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
Rob Hale
 
Load testing with Visual Studio and Azure - Andrew Siemer
Andrew Siemer
 
Road to Continuous Delivery - Wix.com
Aviran Mordo
 
Practicing Red, Green, Refactor!
XPDays
 
CBDW2014 - Behavior Driven Development with TestBox
Ortus Solutions, Corp
 
Testing Tools Online Training.pdf
SpiritsoftsTraining
 
Bigger Unit Test Are Better
Peter Schuler
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Dinis Cruz
 
Testing the Untestable
Mark Baker
 
Agile testing
Raj Indugula
 
Improving the Quality of Existing Software - DevIntersection April 2016
Steven Smith
 
Improving the Quality of Existing Software
Steven Smith
 
How to Automate your Enterprise Application / ERP Testing
RTTS
 
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
AgileNetwork
 
SledgehammerToFinebrush_Devnexus_2021
Shelley Lambert
 
Westrich spock-assets-gum
Brian Westrich
 
Software Testing_A_mmmmmmmmmmmmmmmmmmmmm
IwannatelluAstorylas
 
Ad

Recently uploaded (20)

PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
July Patch Tuesday
Ivanti
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
July Patch Tuesday
Ivanti
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Ad

Agile Work Quality: Test Driven Development and Unit Tests

  • 1. Agile Work Quality: TDD and Unit Tests Keith Callis Principle Consultant, Strategic Data Systems [email protected]
  • 2. About Keith Callis Principal Consultant at SDS, Inc., based in Cincinnati.  Software developer.  Scrum Master (Scrum Alliance). Current agile projects:  (Pivotal Tracker) SQL Server conversions.  (Rally) Hadoop, Oracle, MongoDB, Java, Scala. When not writing or breaking software, he is amateur photographer or chef in his kitchen.
  • 3. Strategic Data Systems – What we do: We work with our customers to improve their business with technology. Our professional services include: Application Development and Application Renovations Architecture, Development, and Architectural Design Reviews .NET, Java Agility - Agile Coaching and Transformations Training - Agile, .NET Our place or yours! We are looking for .NET/Java developers, Scrum Masters and Product Owners.
  • 4. Agile Work Flow • Epics • Features • Stories • Stories only • Backlog of stories
  • 5. Epics • Work goal • Create Payroll system • New Web site for maintaining customer information • Add searching capability to existing web site
  • 6. Features • Break down of an epic • Payroll system • Maintain staff • Add/Inactivate people • Change pay • Change deductions • Calculate payroll • Grose Pay • Deductions • Net Pay • Make payments • Paper checks • Direct deposit
  • 7. Stories • Break down a feature • Calculate payroll • Gross pay • Hourly • Salaried • Overtime • Bonuses • Deductions • Pre-tax items • 401K • Insurance • HSA • Taxes • Federal • State • Local • SSN
  • 8. Work a story • Description of the work • Ask for more information is not clear • Clear Condition of Acceptance for story • Ask for clarification if not clear or not known how to deliver • Attachments to story that may help • Spreadsheets with existing calculations
  • 9. Time to Start Coding? • Should code “design” take place? • What code should be added? • Where should the code be added? • How to meet “conditions of acceptance” in story? • How to test new code? • Are there existing tests?
  • 10. TDD • Write a Test • Run the Test • Test should Fail • Write just enough code for Test to pass • Run the Test • Test should Pass • Repeat
  • 11. Write Test First @Test public void whenMonthly_thenReturnOneTwelfth() { Double yearlySalary = 12000.0; Double expected = 1000.00; Double actual = salaryCalculation.CalculateMonthlySalary(yearlySalary) ; Assert.assertEquals("Expected Monthly Salary not correct", expected, actual); }
  • 12. Pure TDD • Missed first test • Should have a test that the class exists • Then go with the test for the method
  • 13. Test Values @Test public void whenMonthly_thenReturnOneTwelfthRounded() { Double yearlySalary = 12002.0; Double expected =1000.17; Double actual = salaryCalculation.CalculateMonthlySalary(yearlySalary); Assert.assertEquals("Expected Monthly Salary not correct", expected, actual); } java.lang.AssertionError: Expected Monthly Salary not correct Expected :1000.17 Actual :1000.1666666666666
  • 14. Code Change public double CalculateMonthlySalary(double annualSalary) { return annualSalary / 12; } ______________________________________________ public double CalculateMonthlySalary(double annualSalary) { return Math.round(100.0 * annualSalary / 12) / 100.0; }
  • 15. Edit Code Again public SalaryCalculationImpl(double salary, double periods) { this.annualSalary = salary; this.periods = periods; } public void CalculateMonthlySalary() { this.salary = Math.round(100.0 * annualSalary / periods) / 100.0; }
  • 16. Test Passes, Wrong Check @Test public void whenMonthly_thenReturnOneTwelfth() { Double yearlySalary = 12000.0; Double expected = 1000.00; salaryCalculation = new SalaryCalculationImpl(yearlySalary, 12); salaryCalculation.CalculateMonthlySalary(); Assert.assertNotNull("SalaryCalculation object not null", salaryCalculation); }
  • 17. Test Passes, Better Check @Test public void whenMonthly_thenReturnOneTwelfth() { Double yearlySalary = 12000.0; Double expected = 1000.00; salaryCalculation = new SalaryCalculationImpl(yearlySalary, 12); salaryCalculation.CalculateMonthlySalary(); Assert.assertEquals("Expected Monthly Salary not correct", expected, salaryCalculation.getSalary(), 0); }
  • 18. TDD Drive Code Design • As tests are written • Minimal code gets written • No extra/dead code gets written • New code added to pass new tests • Lowers chance for code that cannot be tested
  • 19. No TDD, but Unit Tests • Write a little new code • Method • Class • Write tests for new code • Runs risk of not testing all paths of code
  • 21. Code First, Test Later • Write most of program first • Try to write unit tests • Takes more time • Some code may not be able to be tested • Can result in less code coverage
  • 22. Write Code, Toss Over the Wall • Write program • No tests • Let someone else test • QA tester • Not all paths tested • If test fails, harder to locate failing code
  • 23. Unit vs Integration Tests • Unit test • Just code (class/method, maybe multiple classes) • No external resources (database, file) • Integration test • Code accessing external resources (database, file) • Harder to setup • Harder to validate results
  • 24. Many Unit Tests • Allows more confidence when making changes to code • Example for new story for a found defect • Create new unit tests that fail • Update code for new unit tests to pass • Run ALL unit test to insure no impact on other areas of code
  • 25. “Eat the dog food” • All unit tests pass for programs • However, issue when programs used in final system • Web site • Production data • Program being called by other programs
  • 26. Handle Multiple Conditions • Example handling batches, e.g. batch size 100 • Unit test passes using value of 100 • Unit test fails using value of above or below 100 • Remember to handle multiple values with multiple unit tests • Zero • One • More than one • Null • Negative
  • 27. Tests and Story’s COA • Depending on PO and COA and Story • One or two unit tests may allow story to be accepted • An integration test may allow story to be accepted
  • 28. Story’s COA and Tests • Unit tests can be written for well written COA’s • This can drive out more details for story • More COA’s may be needed for found conditions • Original COA’s handled “good path” • Unit tests points out “invalid paths”
  • 30. Test Early, Test Often image from https://brockbiv.wordpress.com