Mastering Test-driven Development Using JUnit 5

Live Classroom
Duration: 5 days
Live Virtual Classroom
Duration: 5 days
Pattern figure


This extensive course is designed within an engaging hands-on learning environment to equip participants with an in-depth understanding of Java programs, sound code testing techniques and best coding practices. The course covers an introduction to the features of JUnit and discusses JUnit’s strengths and weaknesses. The project exercises are specifically oriented towards using TDD to implement a complex and multi-faceted web application that uses a database in its final form. The course combines expert lectures with open discussions and high-level demonstrations.

What You'll Learn

  • Understand JUnit
  • Understand and use the JUnit test runner interface
  • Use JUnit to drive the implementation of java code
  • Test applications using native IDE support
  • Best practices and patterns for test development
  • Understand JUnit’s strengths and weaknesses
  • Understand the role of debugging when done in conjunction with tests
  • Understand not only the fundamentals of the TDD using java but also its importance, uses, strengths and weaknesses
  • Understand how JUnit affects your perspective on development and increases your focus on a task
  • Learn good JUnit coding style
  • Create well-structured JUnit programs
  • Compile and execute programs using JUnit, jWebUnit, and DBUnit using the IDE of your choice
  • How to extend testing with mock objects using EasyMock
  • Look at refactoring techniques available to make the code as reusable/robust as possible
  • Discuss various testing techniques


The course also covers specific java 8 features including:

  • JUnit 4.x
  • EasyMock (The course can be delivered with Mockito rather than EasyMock, if desired)
  • PowerMock
  • jWebUnit
  • DBUnit


  • Test, code, refactor, repeat
  • The ROI of TDD
  • Rationale
  • Advantages
  • Tools

  • Purpose of unit testing
  • Good unit tests
  • Test stages
  • Unit testing vs integration testing
  • Understanding unit testing frameworks

  • JUnit overview
  • How JUnit works
  • Launching test
  • Test suites
  • JUnit test fixture

  • Test execution cycle
  • Checking for exceptions
  • Using timeouts

  • About hamcrest
  • The hamcrest matcher framework
  • Hamcrest matchers

  • Injecting the parameter
  • Setting the parameters
  • Test execution cycle
  • Observations

  • Writing theory enabled tests
  • Defining datapoints
  • Defining theories
  • Observations

  • “Good” tests
  • Bad smell
  • White-box unit testing
  • Black-box unit testing
  • Automation and coverage

  • Web client-side testing
  • Differences between jWebUnit and JUnit
  • How to implement jWebUnit tests

  • Why we use test dummies
  • Mock objects
  • Working with mock objects
  • Using mocks with the user interface
  • Mock object strategies

  • EasyMock description and features
  • EasyMock object lifecycle
  • Create/expect phase
  • Replay/verify phase
  • Mocking complex objects
  • EasyMock HOWTO

  • PowerMock description and features
  • PowerMock object lifecycle
  • Mocking a static method

  • State-based testing
  • Interaction-based testing
  • Mock objects support each approach
  • Three areas to check in a test

  • Refactoring overview
  • Refactoring and testing
  • Refactoring to design patterns
  • Naming conventions

  • Setting up DBUnit
  • Defining a dataset file
  • Writing a DBUnit test class

  • JUnit and Ant
  • The Ant JUnit tag
  • Running JUnit tests from Ant
  • Generating a JUnitReport

Resources on TDD
Ripple wave

Who should attend

This is an intermediate-to-advanced level Java course, designed for developers who wish to get up and running on test-driven development immediately.

This course is highly recommended for:

  • Senior Java developers
  • Senior software developers
  • Lead software engineers


Participants should be familiar with Java and object-oriented technologies. Real world programming experience is a must.

Interested in this Course?

    Ready to recode your DNA for GenAI?
    Discover how Cognixia can help.

    Get in Touch
    Pattern figure
    Ripple wave