Instructor-led training
Java Testing with JUnit 5 Training in Leawood, Kansas
Private Java Enterprise Edition training for organizations from Hartmann Software Group, delivered onsite in Leawood, Kansas or live online.
What you'll learn
Private Training for Teams
This course is offered as private, instructor-led training for organizations, onsite in Leawood, Kansas or live online. Dates, delivery format, and course content are arranged around your team's requirements.
This course is not currently scheduled as a public class for individual enrollment.
Request Group TrainingPrerequisites
Course Outline
What makes testing with JUnit 5 and Mockito hard to master
Writing an assertion is easy. The harder skills are deciding what to test, isolating it, and keeping tests repeatable. The syllabus builds these in order.
- Core mechanics first (Session 1). Test methods, assertions in depth, assertion messages, and the fixture callbacks
@BeforeEach/@AfterEachand@BeforeAll/@AfterAll. A common misconception is that tests share state. The lifecycle topic is where you learn how instances and fixtures are scoped, and why order-dependent tests become fragile. - JUnit 5 is not JUnit 4 with new annotations (Session 2). The course covers extensions, callbacks and insertion points, conditional execution, parameterized tests, nested tests and JUnit 4 migration. The extension model replaces older runner and rule habits. The Java 8 features the library relies on (lambdas, for example in assertion groups and timeouts) get a primer.
- Running tests is its own topic. IDE support, Maven, the JUnit Platform Console Launcher, and test discovery and selection matter because a test that passes in the IDE but is never picked up by the build gives false confidence.
- Mocking (Session 3). Stubbing, argument matchers, spies for partial mocking, and dependency injection with mocks. The usual trap is over-mocking, which produces tests that restate the implementation instead of checking behavior.
- Enterprise layers (Session 4). Standalone versus in-container testing across persistence, service and web components. Database tests raise repeatability and independence problems, which the course addresses with embedded databases and automatic transaction rollback.
Who it suits and what to take around it
The course is general level and runs two days. It assumes good working knowledge of Java and object-oriented design, including interfaces, abstract classes, collections, factories and generics. Lambda experience helps but is not required. It suits developers new to unit testing, and developers who know JUnit 3 or 4 and need to move to JUnit 5. Training managers can use it to align a team on one testing approach. The version named in the course material is Java SE 8, which is in Extended Support only, until December 2030. Organizations on newer Java releases can ask for private training tailored to the versions they use through a training proposal.
Session 4 tests persistence, service and web components. Teams building those layers may find it useful to learn the layers themselves first. Fast Track to EJB 3.2 (JEE 7 level) and JPA2 covers the persistence and component side. Developing Java EE Web Applications (JEE6/JEE7), plus JPA and REST covers the web side. Other options are listed in the Java Enterprise Edition course guide.
Illustrative scenarios
The scenarios below are illustrations of how the course material can be applied. They are not descriptions of specific organizations or of the course's lab exercises.
- Migrating an existing suite. A team maintaining a large JUnit 4 test base might use the JUnit 4 migration topic, along with nested tests and parameterized tests, to restructure repetitive tests. They would move to the JUnit 5 extension model and adopt a consistent naming and fixture convention.
- Testing a service with collaborators. A developer might use Mockito stubbing, argument matchers and the MockitoExtension to test a service class without its repository or remote client. A spy could cover a class that cannot be fully replaced, with dependency injection of mocks reducing setup code.
- Making database tests repeatable. A team whose persistence tests fail intermittently because they leave data behind might compare an embedded database with mocks or fakes. They could then apply automatic rollback, so each test starts from a known state and does not depend on the others.
AI coding assistants and testing
AI coding assistants are good at drafting boilerplate: a test class skeleton, a set of assertions for an obvious method, or a parameterized test's data table. They are also useful for suggesting edge cases you had not listed.
They fail in ways specific to these topics:
- Mixed JUnit generations. Generated code can combine JUnit 4 and JUnit 5 imports and annotations, or use runner and rule idioms that the extension model replaces. The tests may then compile but not run as intended.
- Over-mocked tests. Assistants often mock everything, so the test passes while verifying nothing about real behavior. Misused argument matchers and misplaced spies are also common.
- Weak database tests. Generated tests may ignore transaction rollback and leave data behind, which breaks test independence.
- Shallow assertions. A test can run the code yet assert almost nothing.
To verify, run the tests through the build as well as the IDE, so you know they are discovered. Then deliberately break the code under test and confirm the test fails. Check that tests pass in any order and on repeated runs. Check the output against the project's Java and library versions, since the course material names Java SE 8.
Frequently asked questions
What level is this course, and who is it for?
It is a general-level, two-day course for developers who already know Java and object-oriented design. It suits those new to testing and those who know JUnit 3 or 4 and want to work with JUnit 5.
Do I need to know Java 8 lambda expressions?
Not strictly. Experience with them helps, and the course includes a short primer on the Java 8 features JUnit 5 uses, covered as needed.
What does the course cover beyond JUnit itself?
The syllabus includes Mockito (mock creation, stubbing, argument matchers, spies and dependency injection with mocks). It also covers standalone versus in-container testing and testing the persistence, service and web layers.
Can the course be delivered privately for our team?
Yes. HSG delivers private training for organizations, onsite at the client's location or live online.
Can the content be customized?
Private courses can be customized, including to the technology versions your organization uses. You can describe your needs through a training proposal request.
Training locations
Java Testing with JUnit 5 training across the U.S. and beyond.
We provide private Java Testing with JUnit 5 training for organizations, onsite at your location or live online, 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
- For a single employee or an entire team
- Flexible scheduling
- Experienced instructors
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.