Choose your language:

Hong Kong
New Zealand
United Kingdom
United States

Introduction to Test-Driven Development (TDD) for Java

Course Code



2 Days

Must have one year experience in developing software and have basic knowledge of Java and Object-Oriented Design.
This intensive, hands-on workshop provides participants with an introduction to Test-Driven Development (TDD). During this two-day experience, participants will learn that the adoption of Test-Driven Development (TDD) is a critical, foundational success factor for Agile and DevOps projects.

Participants will learn and apply the workflows and techniques of TDD. These workflows and techniques lead to better designed solutions by guiding teams to more thoroughly and thoughtfully consider the requirements and implementation of their solution. In addition, the resulting set of tests serve as a safety net allowing the team to make changes, move quickly and maintain confidence in the state of their code.
This course is designed for Java Developers and Architects that are seeking to improve solution design, deliver higher quality code, and proceed more quickly and with more confidence when introducing change into their solutions.

In this course, participants will:

  • Describe the value and impact of TDD in modern agile development efforts
  • Design and develop effective and useful unit tests
  • Apply the TDD workflow and best practices
  • Apply the appropriate test double strategy
  • Identify code and design shortfalls that require refactoring
  • Use refactoring strategies
  • Combine TDD into automated DevOps efforts
  • Measure the impact of TDD
  • Compare TDD and BDD approaches
  • Describe challenges and strategies for succeeding with TDD within an organization

Day 1


Working in the lab setting

Overview of TDD
Advantages\Challenges of Pairing
Introduction to JUnit

TDD, Agile, and DevOps
The Agile Manifesto
The Role of TDD in Agile and DevOps

Unit Testing Background
What is a Unit Test
Unit Test Best Practices
Black Box vs. White Box Test

Unit Testing Frameworks
What is a Unit Test Framework
What is a Test Harness
How Does xUnit Work?
Introduction to JUnit
LAB 1 (80 Mins): Creating and Executing a JUnit Test:

  • Review Existing Java Classes
  • Write a small set of JUnit test classes

Red, Green, Refactor
Do’s and Don’ts of Unit Tests
Test First vs. Test After
The TDD Workflow: Red, Green, Refactor
Best Practices and Pitfalls

Understanding Requirements
Deciding What to Test
What is a User Story?
Acceptance Criteria
LAB 2 (90 Mins): The TDD Workflow: Red, Green, Refactor:

  • Review User Stories
  • Create Test Cases
  • Write Code
  • Refactor

Code Smells, Technical Debt and Design
Common Code Smells
Technical Debt

Addressing Technical Debt
Tests and Design
Refactoring to Patterns
Improving Design via Testing
LAB 3 (90 Mins): Refactoring Code:

  • Identify and correct common code smells\issues to improve code quality
  • Use tests to confirm that components continue to perform as required

Test Doubles
Test Doubles (Fakes, Stubs, Mocks)
Introduction to Mockito
LAB 4 (90 Mins): Use Test Doubles:

  • Use Fakes to Support Testing
  • Use Stubs to Support Testing
  • Use Mockito to Support Testing

Day 2

Testing Targets and Strategies

Challenges and Strategies of Testing Different Targets: GUIs and Databases
RESTful Services
Web Containers

TDD and Legacy
Challenges of Legacy Systems
Growing Test Suites
LAB 5 (80 Mins): Add Tests to Legacy Code:

  • Review Legacy Code
  • Identify and Prioritize Test Cases
  • Create and Execute Top Priority Test Cases

Testing Strategies in DevOps
Lecture (45 Mins)
Test Coverage and Prioritization
Automated Build and Test Execution
Maven, Jenkins and Testing

Code Coverage
Cobertura Code Coverage
JaCoCo Code Coverage

Testing in Automated build

Succeeding with TDD
Organizational Challenges

Getting Traction
Test Management and Maintenance

Testing Metrics

Refactoring Unit Tests
Refactoring Tests
LAB 6 (80 Mins): Refactor a set of JUnit Tests

  • Review set of JUnit Tests
  • Refactor JUnit Tests

Review and Discuss Learning Outcomes
Discuss the References\Sources
Class Discussion on Next Steps
Iterative and Incremental

Send Us a Message
Choose one