SPA2005 session: Rightsizing your unittests

One-line description:Workshop for finding the 'right' size for a unit test.
 
Session format: Workshop [read about the different session types]
 
Abstract:With the growing popularity of XUnit unit testing has become common practice. However unit tests are written in many different ways; some like their units small, many somewhat larger. All this independent of the goal of the unit test in question (merely testing purpose or as a design technique).

Largely we recognize three different approaches. The first takes a class as a unit and makes use of mockobjects extensively to enable the class to be totally separated from it's environment and testing both the provided and required interfaces of the class.

The second approach takes small groups of classes as a unit and aims to reduce the effort to separate the classes from their environment.

Thirdly, we often see the second approach degenerate in a form where large chunks of the business /domain logic is tested in one go and stubs or mockobjects are used substitute resources suh as a datamanagement layer.

Some say that using mockobjects extensively helps improving your design, for using mocking extensively keeps you focused on reducing logical dependencies. Others feel that using small groups of classes as a unit makes them go faster, as mockobjects allow refactoring without the need for changing the test, even if the refactoring is one like "extract class" or "hide delegate".

In this session we aim to find the 'right' size for a unit test. We will explore these three aproaches using a number of examples, with the goal of discovering when each is appropriate.

We will work on real tests on real code but note that this is not a session to promote the use of mocks!
 
Audience background:Developers/ Architects/ Development Coaches. Preferably the attendants have some experience in unit testing / TDD.
 
Benefits of participating:Participants will learn what issues to consider and when to apply different approaches to unit testing
 
Materials provided:None
 
Process:Schedule

00:00 - 00:15 Introductory presentation
00:16 - 00:45 Walkthrough examples
00:46 - 01:15 Group evaluation and exercise 1
break
01:16 - 02:00 Group evaluation and exercise 2
02:01 - 02:20 Facilitated open discussion
02:21 - 02:30 Wrap-up summary

Using code examples to explore useful measures, groups will chose features to evaluate about the test examples, and apply them. Attendees may bring their laptops, as this may help in the session (though not necessary).
 
Outputs:Poster, and feedback trough wiki (XPDeveloper/ XP-NL)
 
History:None
 
Presenters
1. Rob Westgeest
Agidem
2. Paul Simmons
Rochester Software House
3.