Why ?
test writing is like this
Are we making the right tradeoff?
manually checking that stuff works in staging,
freeze and deploy
vs.
complete test suite
vs.
partial test suite and manual verification
Motivation
ship stuff that works
minimize failure demand
but...
can I stay out of the debugger and save time as well?
Got test suite?
refactor with confidence
documentation that doesn't go out of date
BDD only
communicate to stakeholders what's done
test driving
'meh'
'go away'
'why are u pushing this stuff'
I wanna do it like in the movies
Test drive
stay out of the debugger
code guaranteed testable
analysis and code ready for change
Test drive
stay out of the debugger
up front costs 'cause you have to learn
Acceptance test drive
ATDD is another tool in the box to facilitate goal oriented communication and get everybody on the same page. It is about defining in a non-ambiguous way what is desired.
Stephan Schwab
methods
IoC & Dependency Injection
aid in writing testable code
Test Doubles
isolate code under test
Methods...
TDD evolved to BDD
red, green, refactor
communicate
ATDD
implement the right thing
IOC
public static void main() {
Car car = new Car('red');
car.drive(200);
car.fillUp();
car.turnRight();
car.turnLeft();
}
class Simulator {
private Car car;
Container(Car car) {
this.car = car;
}
void run() {
car.drive(200);
car.fillUp();
...
IoC
1983
Richard E. Sweet
DependeNcy injection
IoC
implementation
with contextual lookup
... enable the use of Test Doubles
Test doubles
Spy
Stub which records on how it was called
Mock
specification of expected calls
... enable us to write concise non brittle tests
Dummy
pass around but never used
Fake
actual replacement component
Stub
returns specific values for a test
TDD
1960
'practice of test-first development, planning and writing tests before each micro-increment'
'To shorten the total development time, some formal test documents (such as for acceptance testing) have been developed in parallel (or shortly before) the software is ready for testing. '
NASA Project Mercury
to put a man in space
TDD: So gagarin made it first?
April 12 1961
test driving failed to ship?
TDD
1979
the art of software testing
Separate debugging from testing
Glenford J. Meyers
TDD
2003
TDD rediscovered
Kent Beck XP fame
red, green refactor iterations
keep programmer focus
save time keeping out of debugger and avoid waste
BDD
2006
BDD, an evolution from TDD
Dan North
'I kept coming across the same confusion and misunderstandings. Programmers wanted to know where to start, what to test and what not to test,
how much to test in one go, what to call their tests, and how to understand why a test fails' (http://dannorth.net/introducing-bdd/)
ATDD
1960
NASA project Mercury
1996
realistic examples as a single source of truth
WyCash+ Project
Ward Cunningham
2002
Specification by Example
Martin Fowler