Skip to main content

Instructor-led training

Java Testing with JUnit 5 Training in Johnson City, New York

Java Enterprise Edition training from Hartmann Software Group, delivered onsite in Johnson City, New York or live online.

What you'll learn

This course 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.
 
Testing with mocks is covered in detail, using Mockito. Mocking is a standard technique, and we’ll go beyond the basics to introduce more flexible options, as well as Mockito’s dependency injection facilities. We use the new MockitoExtension to integrate Mockito into JUnit tests.
 
We explore testing enterprise components in the persistence, service, and web layers, outlining the issues involved in each. In the persistence layer, we show how to set up and use an embedded database, and contrast this to using mocks or fakes as a standalone alternative. We examine the unique issues in database testing with regard to test repeatability and independence, using various techniques for auto-rollback of transactions.
 
In-container testing is introduced as a more meaningful approach to testing enterprise components, vs. standalone testing with mocks, and we examine this at each of the main layers in an enterprise application.
 
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.

Prerequisites

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 and covered if necessary.

Course Outline

Session 1: Unit Testing with JUnit 5
Overview
Introducing JUnit 5
JUnit 5 Library Components
Writing and Running Tests
Tests and Assertions
Test Methods
Assertions in Depth
Assertion Messages
Test Fixtures and Lifecycle
@BeforeEach, @AfterEach
@BeforeAll, @AfterAll
Test Lifecycle
 
Session 2: Writing and Running Tests
Java 8 Features Used in JUnit 5
Additional Testing Needs - Exceptions, Timeouts, Assertion Groups
Running Tests
IDE Support
maven support
JUnit Platform Console Launcher
Test Discovery and Selection
Test Configuration
Nested Tests
Advanced Capabilities
Extensions
Callbacks and Insertion Points
Conditional Test Execution
Parameterized Tests
JUnit 4 Migration
Best Practices
 
Session 3: Testing with Mocks
Overview and Mockito Introduction
Creating and Using Mocks
The Mockito Class and Mock Creation
Mock Creation with JUnit 5
Stubbing
Additional Capabilities
Argument Matchers
Partial Mocking with Spies
Dependency Injection with Mocks
 
Session 4: Testing Enterprise Components
Overview
Types of Testing
Standalone vs In-Container Testing
Testing the Persistence Layer
Testing Services
Testing Web Components

Training locations

Java Testing with JUnit 5 training across the U.S. and beyond.

We provide Java Testing with JUnit 5 training onsite and live online for organizations throughout the United States and internationally.

View all Java Testing with JUnit 5 training locations

Train your team with HSG

Private, instructor-led training customized for your organization.

  • Onsite or live online delivery
  • Customized curriculum
  • Training for groups of 3 or more
  • Flexible scheduling
  • Experienced instructors
Request a Training Proposal

Questions? Call us at 303.377.6176
or email info@hartmannsoftware.com

Ready to train your team?

Let's customize this training for your organization.

Tell us about your employees, your goals, and your preferred schedule. We'll prepare a training proposal covering scope, delivery format, and pricing.