Test Driven Development (TDD) in Java

Tools, patterns and techniques for writing well-designed and testable code

Test-driven development is one of the key enablers for agile development, that allows us to develop stable and refactorable code, whose intent is clear and whose design can evolve incrementally. TDD allows us to capture and validate the rules governing the behaviour of our code. There's a bunch of interesting tools available to assist us in developing robust tests, in identifying which tests to write, to help us compose tests and to automatically run our tests. 

Course Code
2 Days
Delivery Style
Course Type
Private Only
Max Delegates
Available as Nutshell

Book your team training at your premises

  • Date
  • Venue
  • Cost
  • More info
Purpose of this course

The training course combines lectures with practical exercises that help the delegates to put what they have learned on the training course into practice.  The exercises specifically build on what has been recently taught and are built up as the training course progresses.

Who is this course for

This training course is aimed at Java developers and analysts, typically in the context of adopting agile development practices. 

You will learn how to
  • Use the JUnit and mocking libraries to write tests
  • Run tests from an IDE and from Maven build scripts
  • Apply patterns and practices for writing testable code
  • Extend the scope of tests into analysis, design and documentation
  • Use tests to communicate with the customer 
Benefits for your organisation

TDD offers a wealth of benefits to your organisation, it can cut development costs for example.  Shorten the development Time to Market and increase the programmer’s productivity.  As well as encouraging the writing of quality code.

Benefits for you as an individual

TDD has many benefits but it can be hard to learn alone.  This course will help you write effective, organized and neat code that works.  It will teach you how to shorten the development feedback time and provide proof that your software code works as intended.


Why test-driven development?
Is TDD necessary?
TDD is about...

Getting Started

Separating code from tests
Package structures
JUnit 4 basics
JUnit setup/teardown

Writing Tests

Base test classes
Naming / Organization
Implementation strategies
Exploring APIs
Parameterized test runners 


Equals and value objects
Seams and sensing
Seam types
Singletons and Statics
Dependency injection 

Test Doubles

Test double taxonomy
Mocking Libraries such as Mockito and PowerMock
Setting Expectations and Verifying Interactions
Mocking Gotchas
Testing Legacy Code 

Understanding the Code through Tests

Showing the Call Hierarchy
Generating Documentation from Tests
Parsing the Test Source Code
Fluent Interfaces 

Organising Tests

Test Suites
Explicitly-built Test Suites
Implicitly-built Test Suites
Filtering and Sorting

TDD in Context

Relationship to Other Agile Practices
Closing Discussion 

More on fixtures

Making the Context Concrete
One-time Setup for Classes
One-time Setup for Suites
Fixtures and Superclasses
Object Mothers
Fixtures as Objects
Data-driven Fixtures
Using Databases
Testing Database Code


Tests vs Theories
Triangulating Tests
Parameter Suppliers

Tests as Specification

The Trouble with TDD
Behaviour Driven Design using jBehave
Customer Acceptance Testing using Concordion

Raising the Bar

Cost of Change Over Time
Code Analysis Taxonomy and Tools
Code Audits
Code Metrics
Cyclomatic Complexity
Code Coverage


Delegates should have some appreciation fo rthe issues involved in building large-scale applications. Delegates should also have a development background.

About the Lead Trainer

Our Agile ‘evangelist’, it’s safe to say that Howie lives and breathes an Agile life. Never to be seen without a pack of post it notes and a sharpie pen in his back pocket, Howie coaches and trains our customers by sharing his passion for more efficient ways of working.