SPA Conference session: TDD at the System Scale

One-line description:A hands-on tutorial teaching techniques for test-driven development at large scales, starting development with end-to-end tests at the system or system-of-systems level.
 
Session format: Long tutorial (330 mins) [read about the different session types]
 
Abstract:If you address integration and system testing as early as possible in a project, the system you are building is always in a deployable state and the project can be more "agile" because new features can be put in front of users as soon as is deemed necessary.

However, many teams applying TDD leave integration and system testing until late in the project because they find it too difficult to write tests that cope with the distributed architecture and concurrent behaviour of their system.

This tutorial demonstrates how to test-drive development starting with end-to-end system-tests and avoid common pitfalls, including unreliable tests, tests that give false positives, slow-running tests and test code that becomes difficult to maintain as the system grows.

This tutorial will answer the questions:
* Where does system testing fits in to the TDD process?
* How can I start with integration, packaging, deployment and end-to-end testing before the code to be integrated is written?
* How do I cope with distribution and concurrency when testing from outside the system?
* How do tests drive architectural decisions?
* How do tests improve the system's large-scale internal quality -- manageability, supportability, etc.?

This exercise requires a laptop with a Java (JDK 1.6) development environment. However, the techniques taught are applicable to any language and environment.
 
Audience background:Experienced Java programmers with some experience of TDD.
 
Benefits of participating:To learn some techniques for addressing tricky TDD issues: asynchrony, concurrency, system architecture.
 
Materials provided:Example code, student notes.
 
Process:A combination of short presentations and hands-on programming exercises
 
Detailed timetable:To be completed...

00:00 - 00:45 Introduction

Overview of TDD: multiple cycles, TDD vs Unit-TDD, starting with end-to-end testing.

Ports and adapters architecture, different kinds of tests exercising different scales of the architecture.

Example real system (computation grid, AJAX GUI, pub/sub and reliable
messaging, databases, web services and web cache hierarchy) to show
typical scale and physical architecture.

Problem of end-to-end testing: you don't know how long anything will take or when it fails. Typical problems (flickering tests, false positives, slow tests, messy test code). This is a key feature of a distributed system. We address the problem in system tests in the same way as in distributed systems: timeouts. Concrete example in terms of the example system.



00:45 - 01:00 Introduce simpler coding example: shopping till, get project set up.


Part I - Flickering Tests because of lost updates

01:00 - 01:15 First exercise: run the tests. Should see occasional failure.

Q: Can anyone explain why the test fails sometimes?
A: Because test is not synchronising with system before asserting its state.

Introduce prober and assert-within-timeout concept. Succeed Fast vs
fixed timeouts. Max timeout in single place. Mention notifications vs.
polling in passing.


01:15 - 01:45 Exercise: fix and extend the tests.


Part II - Runaway Tests


example scenario: voucher to get free product


Part III - Testing that something does not happen

example scenario: three-for-the-price-of-two (TPOT) deals


Part IV - How Tests Guide System Architecture (talk only)

- externalise spontaneous behaviour
- add synchronisation and monitoring hooks
 
Outputs:
 
History:
 
Presenters
1. Nat Pryce
Technemetis Ltd.
2. Steve Freeman
M3P Ltd
3.