Are you having trouble writing automated tests for your Spring or Spring Boot web app? If so, take a look at my Test With Spring course.

JUnit 5 Tutorial

The long-term goal of this tutorial is to help you to write unit, integration, and end-to-end tests with JUnit 5. That being said, at the moment this tutorial simply helps you to get started with JUnit 5.

This tutorial consists of the following blog posts:

  • Running Unit Tests With Maven describes how you can get the required dependencies with Maven and create a Maven project that runs your unit tests.
  • Running Unit Tests With Gradle describes how you can get the required dependencies with Gradle and create a Gradle project that runs your unit tests.
  • Writing Our First Test Class describes how you can use setup and teardown methods, and add test method to your test class. Note that this post assumes that you have no previous experience from JUnit 4.
  • Writing Nested Tests describes how you can write nested tests with JUnit 5, and leverage setup and teardown methods in your nested tests.
  • Writing Parameterized Tests describes how you can write parameterized tests with JUnit 5.
  • Writing Assertions With JUnit 5 Assertion API describes how you can write assertions with JUnit 5 assertion API, provide a custom error message that is shown if an assertion fails, and group assertions with JUnit 5.
  • Writing Assertions With Hamcrest describes how you can get the required dependencies with Maven and Gradle, write basic assertions with Hamcrest, combine multiple Hamcrest matchers, and provide a custom error message that is shown when an assertion fails.
  • Writing Assertions With AssertJ describes how you can get the required dependencies with Maven and Gradle, write basic assertions with AssertJ, write soft assertions with AssertJ, and provide a custom error message that is shown when an assertion fails.