Java Testing with JUnit 5 and TDD

See Course Outline

Training for your Team

  • Private Class for your Team
  • Online or On-location
  • Customizable
  • Expert Instructors

Training for Yourself

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

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

No cancelation for low enrollment

Certified Microsoft Partner

Registered Education Provider (R.E.P.)

GSA schedule pricing


Students who have taken Live Online Training


Organizations who trust Webucator for their training needs


Satisfaction guarantee and retake option


Students rated our trainers 9.44 out of 10 based on 4957 reviews

This training was clear, step by step, easy to manage and understand. Instructor was very good about going back through steps to help me catch up when needed. The materials given were the best I have ever had!!! I feel very comfortable with going back on the job and using what I have learned.

Shanna Zanolini, VCBH QI
Ventura CA

I thought this class was well worth the money and the time. Can't wait to take the next levels (3 and 4) of Access 2007. The instructor was able to hold my attention and was able to teach very well.

Craig Howell, Vista Engineering
Richland WA

This was my first class with Webucator. They were professional and comparable to any of my corporate sponsored classes. The pace of the class was great and the instructor well informed of the class materials.

Lisa Darrah, Autodesk, Inc.
novi MI

Training felt personalized and highly expert! All the content made sense to me, a business user, because the instructor was technically savvy and very clear.

Terrie Linderman, American Medical Association

Contact Us or call 1-877-932-8228