Java Testing with JUnit 5

  4.4 out of 5 - Read Testimonials

This Java Testing with JUnit 5 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, important new features, and a brand new extension model. Developers with JUnit 3 and 4 experience will be well-served by the course.

All labs are done with the Eclipse IDE, and the lab instructions include detailed directions for setting up and using it. The standard application server used is TomEE, but it is available for other major app servers, including WildFly/JBoss AS and IBM WebSphere AS.


Public Classes: Delivered live online via WebEx and guaranteed to run . Join from anywhere!

Private Classes: Delivered at your offices , or any other location of your choice.

Course Topics
  1. Understand new JUnit 5 library structure, role of each component, and how they interact
  2. Configure IDE projects to run tests natively, and via Maven Surefire
  3. Write cohesive and effective tests, and design classes for testability
  4. Understand the full test lifecycle, and employ it to configure test fixtures
  5. Run tests using all available mechanisms: IDE, Maven, JUnit Console Launcher, Launcher API
  6. Use test discovery and filtering to define and run test plans, including conditional test execution
  7. Employ naming conventions at every level - test name, classname, display name
  8. Organize tests with assertion groups and nested tests
  9. Use test interfaces to apply good OO principles to testing
  10. Understand the new JUnit extension model, and how to write and use them
  11. Understand JUnit 4 compatibility and migration
  12. Use mock objects with Mockito to support isolated testing
  13. Explore Mockito's facilities for dependency injection of mocks
  14. Use argument matchers for more generalized testing with mocks
  15. Implement partial mocking with spies
  16. Understand the issues in testing enterprise components
  17. Understand the two basic approaches: standalone testing with mocks, and in-container testing
  18. Test database access components, using both fakes and an embedded database
  19. Understand the additional issues involved in testing the service and web layers
  20. Exercise best practices throughout the testing effort
  1. Unit Testing with JUnit 5
    1. Overview
      1. Unit Testing and JUnit Overview
      2. New Features in JUnit 5
      3. JUnit 5 Library Components
      4. Naming Conventions and Organizing Tests
    2. Tests and Assertions
      1. Writing Test Methods
      2. Assertions
      3. Assertion Messages
    3. Test Fixtures and Test Lifecycle
      1. Creating and Using Text Fixtures
      2. Test Run Lifecycle: @BeforeEach and @AfterEach, @BeforeAll and @AfterAll
      3. Controlling Test Instances
  2. Writing and Running Tests (includes brief primer on Java 8 new features)
    1. Additional Testing Needs
      1. Testing for Exceptions
      2. Setting Timeouts
      3. Assertion Groups
    2. Running Test
      1. IDE Support: Eclipse, IntelliJ IDEA
      2. Maven Configuration
      3. JUnit Platform Console Launcher
      4. Launcher API
      5. Test Discovery and Selection
      6. Display Names
      7. Grouping and Filtering with Tags
      8. Configuration Parameters
      9. Nested Tests
    3. Advanced Capabilities
      1. Custom Composed Annotations
      2. Inheritance with Test Classes
      3. Extensions
      4. Conditional Test Execution
      5. Parameterized Tests
    4. JUnit 4 Migration
      1. The Do-Nothing Case
      2. Using a JUnit 4 Runner
      3. API Changes
      4. JUnit 4 Runners and Rules
      5. JUnit 4 Test Suites
    5. Best Practices
      1. Testing Void and Private Methods
      2. Test Cohesion and Assertion Scope
      3. Characteristics of Good Tests
      4. Writing Testable Code
      5. Testing Anti-Patterns
  3. Testing with Mocks
    1. Overview
      1. Mock Objects as Collaborators
      2. Mockito Overview
    2. Creating and Using Mocks
      1. Basic Steps in Mocking
      2. The Mockito Class
      3. Mock Creation with @Mock
      4. JUnit 5 MockitoExtension
      5. Stubbing
    3. Additional Capabilities
      1. Argument Matchers
      2. Partial Mocking with Spies
      3. Mocking the Unmockable
      4. Dependency Injection of Mocks
  4. Testing Enterprise Components
    1. Overview
      1. Unit Testing vs. Integration Testing
      2. Testing with Mocks vs. In-Container Testing
      3. Mocks vs. Fakes
    2. Testing the Persistence Layer
      1. Database Options: Installed, Embedded, Embedded-in-Memory
      2. Standalone vs. In-Container Testing
      3. Test Independence and Transaction Rollback
      4. In-Container Testing with Arquillian [Overview]
    3. Testing Services
      1. Similar Issues, Different Layer
      2. Working with External Resources
      3. The Argument for In-Container Testing
    4. Testing Web Components
      1. Interfacing with External Clients
      2. Difficulties in Standalone Testing with Mocks
      3. Manual vs. Automated Testing
      4. Automated Testing with Selenium [Overview]
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.

Class Prerequisites

Experience in the following is required for this Java Fundamentals class:

  • Good working knowledge of Java and OO, including the use of interfaces, abstract classes, collections, factories, and generics.

Experience in the following would be useful for this Java Fundamentals class:

  • Experience with Java 8 lambda expressions is helpful, but not strictly required.

Training for Yourself

$1,150.00 or 2 vouchers

Upcoming Live Online Classes

  • See More Classes

Please select a class.

Training for your Team

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

What people say about our training

The course material was presented at a good pace and the labs helped me see how the concepts that were presented actually work in practice.
Dan Dougherty
Andesa Services
The JavaScript introductory class was very good, mostly due to the very enthusiastic and knowledgeable instructor.
Carol-Ann Manfria
Stryker Orthopeadics
Great class! Great materials! Great instructor!
Mindy Bom
I feel like I know GA inside and out now. I am excited to bring my knowledge back and start applying within my organization.
Kate Ludwig

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 Java Testing with JUnit 5 trainers 8.89 out of 10 based on 20 reviews

Contact Us or call 1-877-932-8228