Java Testing with JUnit 5 and TDD

This Java Testing with JUnit 5 and TDD training class introduces experienced Java developers to the fundamentals and best practices in unit testing. It uses the JUnit 5 and Mockito libraries, both of which are ubiquitous in the Java community. It is intended for both developers who are new to testing, as well as those who are already familiar with it, but want more experience with testing using JUnit 5.
Note that JUnit 5 is substantively different than JUnit 4. Although the core testing principles are the same, there are substantial implementation differences, and developers with JUnit 4 experience will be well-served by the course.

Testing with mocks is covered in detail, using Mockito. Mocking is a "standard" technique, employed almost universally, while TDD (see below) is not, hence our emphasis more on mocking than TDD.

Test-Driven Development (TDD) is not a strict emphasis in the course, though a detailed overview is provided along with hands-on practice using this technique, and can be omitted if not of interest.

Best practices are emphasized and demonstrated throughout, and our goal is to make you "test infected," so that your development effort is as much about good testing and writing testable code as it is about writing the business code itself.

The student is expected to have a good working knowledge of Java and OO, including the use of interfaces, abstract classes, collections, factories, and generics. Experience with Java 8 lambda expressions is helpful, but not strictly required. A brief primer on the Java 8 features employed by JUnit is included in the course to be covered if necessary.

All labs are done with the Eclipse IDE, and the lab instructions include detailed directions for setting up and using it. Support for IBM RAD and IntelliJ IDEA is available with advanced notice and possible additional charges.

  1. Be familiar with and use JUnit 5.
  2. Write and run unit tests with JUnit 5.
  3. Migrate JUnit 4 tests to JUnit 5.
  4. Understand mocking, and use Mockito to test with mocks.
  5. Be aware of techniques for testing enterprise components.
  6. Understand refactoring and use it to produce better code (may not be included).
  7. Understand and use the basic principles of TDD (Test-Driven Development).
  1. Unit Testing with JUnit 5
    1. Overview
    2. Unit Testing and JUnit Overview
    3. New Features in JUnit 5
    4. JUnit 5 Library Components
    5. Naming Conventions and Organizing Tests
    6. Tests and Assertions
    7. Writing Test Methods
    8. Assertions
    9. Test Fixtures and Test Lifecycle
    10. Creating and Using Text Fixtures
    11. Test Run Lifecycle: @BeforeEach and @AfterEach, @BeforeAll and @AfterAll
    12. Controlling Test Instances
  2. Writing and Running Tests (includes brief primer on Java 8 new features)
    1. Additional Testing Needs
    2. Testing for Exceptions
    3. Setting Timeouts
    4. Assertion Groups
    5. Running Test
    6. Configuration Parameters
    7. Test Discovery and Filtering with Tags
    8. Running Tests in the IDE
    9. Configuring a Maven Project for JUnit 5
    10. Running Tests via Maven
    11. JUnit Platform Console
    12. Programmatic Test Runs via Launcher API
    13. JUnit 4 Migration
    14. API Differences
    15. JUnit Vintage TestEngine
    16. Using a JUnit 4 Runner
    17. JUnit 4 Rules and Test Suites
    18. Additional Capabilities
    19. Custom Composed Annotations
    20. Extensions
    21. Conditional Test Execution
    22. Repeated and Parameterized Tests
    23. Nested Tests
    24. Best Practices
    25. Characteristics of Good Tests
    26. Writing Testable Code
    27. Testing Anti-Patterns
  3. Testing with Mocks
    1. Overview
    2. Definition and Motivation
    3. Characteristics of Mocks
    4. Mocks vs. Spies
    5. Creating and Using Mocks
    6. Initialization and Setup
    7. Verifying and Stubbing
    8. Using @Mock
    9. Using Mockito with JUnit 5
    10. Injecting Mocks
    11. Additional Capabilities
    12. Spying and Partial Mocking
  4. Testing Enterprise Components (preliminary)
    1. Overview
    2. Unit Testing vs. Integration Testing
    3. Testing with Mocks vs. In-Container Testing
    4. Mocks vs. Fakes
    5. Testing the Persistence Layer
    6. Testing Services
    7. Testing Web Components
  5. Refactoring (preliminary - may not be included based on time)
    1. Principles
    2. Code Smells
    3. Refactoring and Testing
    4. Handling API Changes
    5. Using IDE Capabilities
    6. Reorganizing Packages and Classes
    7. Renaming Classes and Methods
    8. Extracting Methods
  6. Test-Driven Development (Optional and preliminary)
    1. Overview
    2. Test-Oriented vs. Test-Driven Development
    3. TDD and Agile Development
    4. Principles and Techniques
    5. The TDD Cycle
    6. Advantages and Benefits
    7. Limitations and Challenges
Class Materials

Each student in our Live Online and our Onsite classes receives a comprehensive set of materials, including course notes and all the class examples.

Preparing for Class

Training for your Team

Length: 2 Days
  • Private Class for your Team
  • Online or On-location
  • Customizable
  • Expert Instructors

Training for Yourself

$950.00 or 2 vouchers
  • Live Online Training
  • For Individuals
  • Expert Instructors
  • Guaranteed to Run
  • 100% Free Re-take Option
  • 1-minute Video


Brent Baisden, DLA - Land & Maritime
Orange County CA

An effective mix of the material necessary to pass the exam with the perspective of real-world application.

Sean Raich, The Army and Air Force Exchange Service
Dallas TX

I hadn't done online training before and this was a great way to take a class. It provided a great start to learning HTML5.

Krista Steller, Levi, Ray & Shoup, Inc.
Springfield IL

Very practical, helpful course, delivered personally through the Internet.

Kevin Grose, n/a
New York NY

No cancelation for low enrollment

Certified Microsoft Partner

Registered Education Provider (R.E.P.)

GSA schedule pricing


Students who have taken Instructor-led Training


Organizations who trust Webucator for their Instructor-led training needs


Satisfaction guarantee and retake option


Students rated our trainers 9.47 out of 10 based on 576 reviews

Contact Us or call 1-877-932-8228