Choose your language:

Hong Kong
New Zealand
United Kingdom
United States

Introduction to Test-Driven Development (TDD) for Java

Course Code



2 Days

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 features labs for Java. For C# see AG55.
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.
Upon completion of this course, participants will be able to:
  • 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
Section 1

Overview of Agile Development and DevOps
Traditional Unit Testing
Overview of TDD
Advantages\Challenges of Pairing
The Role of TDD in Agile and DevOps
Introduction to JUnit (Note: Focus on Big Picture and Overview; details are in Lab)

LAB 1 (60 Mins): Creating and Executing a JUnit Test
Review Existing Java Classes
Write a small set of JUnit test classes

Section 2
Red, Green, Refactor

Test First vs. Test After
The TDD Workflow: Red, Green, Refactor
Best Practices and Pitfalls

LAB 2 (80 Mins): The TDD Workflow: Red, Green, Refactor
Review User Stories
Create Test Cases
Write Code

Section 3
Code Smells, Technical Debt and Design

Common Code Smells
Technical Debt
Refactoring to Patterns
Improving Design via Testing

LAB 3 (80 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

Section 4
Test Doubles

Test Doubles (Fakes, Stubs, Mocks)
Introduction to Mockito (Note: Focus on Big Picture and Overview; Details for Mockito are in the Lab)

LAB 4 (80 Mins): Use Test Doubles
Use Fakes to Support Testing (25%)
Use Stubs to Support Testing (25%)
Use Mockito to Support Testing (50%)

Section 5
Testing Targets and Strategies

Challenges and strategies of testing different targets:
RESTful Services
Compare Rest-Assured and Restito
Web Containers

LAB 5 (75 Mins): Test a RESTful Service (Using Rest-Assured)
Review a RESTful Service
Identify and Prioritize Test Cases
Create and Execute Test Cases

Section 6
TDD and Legacy Systems

Challenges of Legacy Systems
Growing Test Suites

LAB 6 (75 Mins): Add Tests to Legacy Code
Review Legacy Code
Identify and Prioritize Test Cases
Create and Execute Top Priority Test Cases

Section 7
Testing Strategies in DevOps

Test Coverage and Prioritization
Automated Build and Test Execution
Maven, Jenkins and Testing

LAB 7 (60 Mins): Coverage, Prioritization, and Automation
Kick-off automated Build, Deploy, Test
Review Test Results and Code Coverage
Enhance Test Coverage
Request Build, Deploy, Test and Review Results

Section 8
Succeeding with TDD

Organizational Challenges
Getting Traction
Test Management and Maintenance
Testing Metrics
Refactoring Tests

LAB 8 (60 Mins): Refactor a set of JUnit Tests
Review set of JUnit Tests
Refactor JUnit Tests

Section 9
Summary, References and Next Steps

Review and Discuss Learning Outcomes
Discuss the References\Sources
Class Discussion on Next Steps
Iterative and Incremental
Send Us a Message
Choose one