JUnit 5 - The Ultimate Resource

Last updated: February 12, 2019

Migrating From JUnit 4

  • JUnit5 Assertion Migration Strategy introduces a strategy that helps you to migrate your assertions from JUnit 4 to JUnit 5.
  • JUnit 5 vs JUnit 4 is a hands-on guide that describes the differences between JUnit 4 and 5. It also provides a list of blog posts that help you to get started with JUnit 5.
  • Migrating from JUnit 4 to JUnit 5 is a practical post that identifies the differences between JUnit 4 to JUnit 5. This information helps you to migrate your existing tests from JUnit 4 to JUnit 5.
  • Migrating to JUnit 5 describes how the author migrated the VocabHunter open source project from JUnit 4 to JUnit 5. This post describes how the author updated his (somewhat complex) Gradle build script and explains how he solved a few other problems such as mocking and passing JVM arguments to his test suite.
  • JUnit 5 User Guide: 6. Migrating from JUnit 4 describes how you can run your existing tests with JUnit 5 and provides tips that help you to make the required changes to your existing tests.
  • Porting Your Existing Tests to JUnit 5 is a hands-on guide that helps you to modify your existing tests to use JUnit 5.

JUnit 5 Architecture

  • JUnit 5 – Architecture is an excellent blog post that provides a comprehensive description of the JUnit 5 architecture. The interesting thing about this blog post is that also describes the reasons behind the design decisions made by JUnit 5 team.

Using Maven and Gradle

Getting Started With JUnit 5

Writing Parameterized Tests

Writing Assertions

Structuring Test Classes

Using Test Doubles

Mockito

WireMock

  • WireMock Tutorial: Introduction provides a quick introduction to WireMock. After you have read this blog post, you can identify the key features WireMock, you understand when you should use it, and you can get the required dependencies with Maven and Gradle.
  • WireMock Tutorial: Configuration describes how you can configure WireMock from the scratch. After you have read this blog post, you can configure the used WireMock server, you know how you can start the WireMock server before a test method is run, and you can stop the WireMock server after a test method has been run.
  • WireMock Tutorial: Request Matching, Part One provides an introduction the request matching support of WireMock. This blog post helps you to understand how request matching works, and describes how you can specify expectations for request methods and request urls.
  • WireMock Tutorial: Request Matching, Part Two describes how you can use the WireMock's request matching support when you want specify expectations for cookies, HTTP headers, and request parameters.
  • WireMock Tutorial: Request Matching, Part Three describes how you can specify expectations for the JSON document that is received by your WireMock server.
  • WireMock Tutorial: Request Matching, Part Four describes how you can specify expectations for the XML document that is received by your WireMock server.
  • WireMock Tutorial: Introduction to Stubbing describes how you can ensure that your WireMock server returns a configured HTTP response when it receives a specific HTTP request.

Filtering the Invoked Tests

Writing Integration Tests

Writing Extensions

  • A Guide to JUnit 5 Extensions provides a quick introduction to the JUnit 5 extension model and describes how you can write your first JUnit 5 extension.
  • JUnit 5 - Extension Model is an excellent blog post that describes the JUnit 5 extension model. The best part of this blog post is that the author identifies the reasons behind the technical decisions made by the JUnit 5 team.
  • Testing System.exit() with JUnit 5 describes how you can write a custom JUnit 5 extension which allows you write tests for System.exit().

Extensions