<<< Previous speaker Next speaker >>>

Romilly Cocking, Independent Consultant

 Romilly  Cocking Romilly Cocking is a member of the Highgate Guild of Software practitioners. He consults best practices for Agile Development, team dynamics, domain specific languages, code generation, tools to aid thinking and decision making (Mind Maps, Topic Maps etc.), metacognition (Thinking about Thinking) and computer-assisted learning.

Tutorial: "TDD with MockObjects"

Track:   Tutorial

Time: Tuesday 09:00 - 16:00

Location: Wesley Room

Abstract:

This hands-on tutorial teaches Test-Driven Development and MockObjects using the JUnit and jMock 2 libraries. We will cover: What is Test-Driven Development? Why is it so widely used in Agile projects? What are Mock Objects and where do they fit into the TDD process? How are tests and Mock Objects used to drive good object-oriented design.


We will touch on: What should, and should not, be mocked? How do youwrite flexible tests that do not break when you make unrelated changes to the code? How do you use the tests to identify issues with the design and how do you fix those issues?

Program

We will start by presenting an overview of TDD that addresses thefollowing questions:

What is Test-Driven Development?Why is it so widely used in Agile projects?What are Mock Objects and where do they fit into the TDD process?How are tests and Mock Objects used to drive good object-oriented designThe presentation will conclude by describing the scenario that wewill use for the pair programming exercise to come.

We will then introduce the jMock 2 API through a live demonstration,writing the first test of the exercise and then just enough code tomake it pass.

The participants will then work in pairs to implement the first testfor themselves and continue with the exercise. The exercise will berun in iterations. After each iteration the participants will sharethe lessons they learned with the group and we will present moredetailed explanations of the issues raised. The exercise anddiscussions will answer the following questions:

What should, and should not, be mocked?How do you write flexible tests that do not break when you makeunrelated changes to the code?How do you use the tests to identify issues with the design and howdo you fix those issues?We will wrap up the session with a further presentation reiteratingthe lessons learned and looking at them in more detail, with good andbad code examples.

Note

Intended audience and experience level:Developers (any level) Knowledge of Java.

Prerequisites:Laptop (including power cable!) Java development environment