Tutorials
Test-Driven Development
This tutorial demonstrates the development of a small system using test-driven development and supporting technologies. The system will comprise a handful of Java classes that exemplify typical components found in enterprise applications, including domain objects, a service layer, and gateways.
The tutorial presents two complementary approaches to TDD: state-based testing and interaction-based testing. Both approaches will be discussed in depth during the development of the system, and benefits of each approach will be highlighted and contrasted. The tutorial also covers common trade-offs and edge case, e.g. how to deal with testing private methods and when not to use dynamic mocks but hand-crafted stub objects. The implementation will use modern technologies such as JUnit 4, Hamcrest, and Mockito.
Attendees will gain an understanding of how proper use of test-driven development fosters good design; through decoupling and interface discovery for example. Attendees will also gather a nice catalogue of the most commonly used patterns used in conjunction with test-driven development.
History:
- JAOO Australia 2009 – Sydney and Brisbane, Australia – with Dan North
- JAOO 2008 – Åhus, Denmark – with Dan North
- JAOO Australia 2008 – Brisbane and Sydney, Australia – with Martin Fowler
- JAOO 2007 – Århus, Denmark – with Martin Fowler
- QCon 2007 – London, UK – with Martin Fowler
- ØreDev 2006 – Malmö, Sweden – with Martin Fowler
- JAOO 2006 – Århus, Denmark
- JavaZone 2006 – Oslo, Norway
- SI-SE 10th Anniversary Symposium – Zurich, Switzerland – with Aslak Hellesøy
Links:
- Mocks aren’t stubs by Martin Fowler
- xUnit patterns
- Mock Objects wiki
[Slides] [Source with Mercurial repository]
Recommended reading
If you want to delve further into this topic we recommend the following two books:
Test-Driven Development
by Kent Beck
The ‘original’ book on test-driven development. Part I gives a detailed introduction into the topic and part II shows advanced techniques by implementing a unit testing framework using a test-driven approach.
Domain Driven Design
by Eric Evans
A great book that covers ‘the other half’ of an agile project. It explains how it is possible to build domain models for complex domains during implementation; and why it is in fact benefitial to not create an abstract (logical) model upfront. Also presents many patterns and addresses strategic design.
I'm Erik Dörnenburg, a veteran software developer with an interest in using visualisation techniques to help people better understand code and architecture.