top of page


Mastering TDD

with JUnit


This course is designed to teach students to design and develop applications using Agile Engineering Practices.  Students learn JUnit and several associated frameworks, Test Driven Development (TDD), Behavior Driven Development (BDD) as well as techniques for refactoring code.  Throughout the course, numerous hands-on exercises and projects reinforce the lecture material, giving students the practical experience necessary for using Agile Engineering Practices on their jobs.


4 Days


This course is a hands on workshop, designed so that participants can use the knowledge, skills and experience they acquire on their jobs. 


By the end of the course, students will be able to:

  • Develop applications using Test Driven Development principles and practices

  • Write and execute tests using JUnit

  • Use tests to drive their designs at the unit and component levels

  • Understand technical debt and its impacts

  • Refactor code to remove technical debt

  • Write and execute tests for an API

  • Use the Mockito framework to create mock objects

  • Develop tests using HttpUnit, 


The course is intended for testers, developers, quality engineers and managers who want a practical course in Test Driven Development using JUnit and associated frameworks.


As programming exercises are included throughout the course, a knowledge of Java is necessary.



Course Topics


Day 1

  • Introduction

  • TDD/BDD/ATDD Overview

  • The 4 Quadrants of Testing

  • The JUnit framework

  • Unit Testing

  • This section contains 9 hands-on exercises


Day 2

  • Unit Testing best practices

  • Designing for Testability

  • Mock Objects and Mocking Frameworks

  • Testing Seams

  • TDD in practice

  • Databases in Unit Testing

  • Measuring Code Coverage Driving Design with Tests

  • This section contains 7 hands-on exercises


Day 3

  • Testing an API

  • Using HttpUnit to test an API

  • Parsing JSON responses

  • Refactoring Principles, Practices and Techniques

  • Design by Intention

  • SOLID Design Principles

  • This section contains 4 exercises and 2 projects


Day 4

Students will use both TDD and ATDD to develop an application in two sprints, starting with User Stories and ending with fully tested, integrated and refactored code.

Detailed Course Outline

I.  Introduction
  • Review of Agile Principles and Values

  • Testing in Agile

  • Quadrant 2 Testing

  • Quadrant 1 Testing

  • Quadrant 3 Testing

  • Quadrant 4 Testing


II.  TDD/BDD/ATDD Overview
  • Test Driven Development Principles

  • TDD Process

  • Behavior Driven Development – Specification by Example

  • Domain Specific Language

  • TDD vs ATDD


III. Unit Testing with JUnit
  • Structure of a Unit Test

  • Creating and Running JUnit tests

  • Assert Statements

  • Refactoring Tests – the DRY Principles and Annotations

  • Testing for Exceptions and Timeouts

  • Execution Paths

  • Boundary Conditions

  • Code Coverage

  • Unit Test Best Practices

IV.  Unit Testing Best Practices
  • Naming Conventions

  • Test Data

  • Refactoring Tests


V.  Design For Testability
  • Untestable Code

  • Coupling

  • Testing Seams and Friendlies

  • Refactoring the Design


VI.  Mock Objects and Mocking Frameworks
  • Mocking Frameworks

  • Mocking Objects

  • Configuring Behavior of Mock Objects

  • When -> Then Return

  • When -> Then Throw

  • When -> Then Answer

  • Annotations

  • Verify

VII.  Testing an API
  • Testing Business Logic vs Testing the UI

  • Http requests and responses

  • Parsing the response

  • Using HttpUnit to test an API


VIII.  Refactoring
  • Refactoring Techniques

  • Refactoring Practices

  • Refactoring in Eclipse

  • Case Study:  The Video Store

  • Case Study:  The Payroll Application


IX.  Designing By Intention
  • Write the Code You Wish You Had

  • SOLID Design Principles


X.  Driving Design with Tests
  • Class Exercise:  The Airport Parking Lot


XI.  Testing an API
  • Basic Principles

  • Communicating with an API

  • Response Codes

  • Class Exercise #1

  • JSON Responses

  • Parsing JSON responses

  • Class Exercise #2

  • JSON arrays as Responses

  • Class Exercise #3


XII.  Class Project
  • Understanding the problem

  • Getting started

  • Sprint 1 Planning

  • Sprint 1 Execution

  • Sprint 1 Sprint Review

  • Sprint 1 Retrospective

  • Sprint 2 Planning

  • Sprint 2 Execution

  • Sprint 2 Sprint Review

  • Sprint 2 Retrospective

bottom of page