Java testing with JUnit 5: unit tests, mocks, coverage

10 steps · about 6 h 50 min · Intermediate

  1. Java Testing - JUnit 5 Crash Course (video, YouTube, 40 min)

    A quick video overview shows what a unit test looks like before you read any documentation.

  2. JUnit 5: Front To Back (FULL COURSE) (video, YouTube, 2 h)

    A longer course goes deeper on assertions, lifecycle and structure once you have the basics.

  3. JUnit 5 User Guide (doc, JUnit (official docs), 1 h)

    The official guide is the authoritative reference for annotations, lifecycle order and the Platform, Jupiter and Vintage modules.

  4. Java Unit Testing with JUnit - Tutorial - How to Create And Use Unit Tests (video, YouTube, 30 min)

    A second walkthrough of writing tests by hand reinforces the habit before you add mocks.

  5. Using Mockito With JUnit 5 (article, Arho Huttunen, 20 min)

    It introduces mocks by building one manually with mock(), then moves to annotations and the extension.

  6. Unit tests with Mockito - Tutorial (tutorial, vogella, 45 min)

    It covers stubbing, argument matchers and verification with runnable JUnit 5 examples.

  7. Mockito and JUnit 5 - Using ExtendWith (article, Baeldung, 15 min)

    It shows how MockitoExtension and @Mock replace manual mock setup in a JUnit 5 class.

  8. Mockito (Mockito 5.15.2 API) (reference, Mockito (javadoc.io), 40 min)

    The official reference lists every feature, such as ArgumentCaptor, spies and strict stubs, for when you need more than the basics.

  9. JaCoCo Code Coverage With JUnit and Maven (Java 25) (guide, HowToDoInJava, 25 min)

    With tests and mocks in place, this explains how JaCoCo measures coverage and how to fail a build on a coverage rule.

  10. Code Coverage with JaCoCo and Maven (article, Naiyer Asif, 15 min)

    It ends by showing how to read the HTML report and set a coverage threshold, so you can judge what the numbers mean.