Download - TDD: What is it good for?
TDDwhat is it
good for?
David Simons
Developer @
Softwire
<3 Databases
Part-time Elf
Automated Testing
Functional Testing
Stress Testing
Unit Testing
Flight Availability
Repository
Flight Availability
Service
Flight Availability
Repository
Flight Availability
Service
Test Double
Flight Availability
Service
Flight Availability Repository
Flight Availability
Service
Flight Availability Repository
isAvailable?
Flight Availability
Service
Flight Availability Repository
no
What is TDD?
Test Driven Development
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
Failing TestMake it PassRefactor
All possible tests pass
@Unroll def "Fib Number #input is #result"() { given: def fibCalc = new FibCalculator() expect: fibCalc.calculate(input) == result }
where: input| result 0 | | 0
int calculate(int input) { 0 }
where: input| result 0 | 0
int calculate(int input) { 0 }
where: input| result 0 | 0 1 | 1
int calculate(int input) { input }
where: input| result 0 | 0 1 | 1
int calculate(int input) { input }
where: input| result 0 | 0 1 | 1 2 | 1
int calculate(int input) { if(input == 0) { return 0 } 1 }
where: input| result 0 | 0 1 | 1 2 | 1
int calculate(int input) { if(input == 0) { return 0 } 1 }
where: input| result 0 | 0 1 | 1 2 | 1 3 | 2
int calculate(int input) { if(input == 0) { return 0 } if(input <= 2) { return 1 } 2 }
where: input| result 0 | 0 1 | 1 2 | 1 3 | 2
int calculate(int input) { if(input < 2) { return input } 1 + calculate(input – 2) }
where: input| result 0 | 0 1 | 1 2 | 1 3 | 2
int calculate(int input) { if(input < 2) { return input } 1 + calculate(input – 2) }
where: input| result 0 | 0 1 | 1 2 | 1 3 | 2 4 | 3
int calculate(int input) { if(input < 2) { return input } calculate(input - 2) + calculate(input – 1) }
where: input| result 0 | 0 1 | 1 2 | 1 3 | 2 4 | 3
The Benefits
Breaking Down
Problems
Testing Anti-Patterns
Regression Testing
DHH
“the test-first rhetoric got louder and angrier”
“look at what that approach is doing to the integrity of your system design”
(I had to
do this)
Is TDD Dead?
Added Complexity
Dogmatism
TDDis it dead?
any
questions?
@SwamWithTurtles