O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JUnit 5 extension for Spring

In order to integrate the spring-test capabilities into JUnit 5's Jupiter programming model, SpringExtension has been developed. This extension is part of the spring-test module, as of Spring 5. Let's see several examples of JUnit 5 and Spring 5 together.

Let’s suppose we want to make an integration in-container test of the Spring application described in the former section, made up of three classes: MySpringApplication, MessageComponent, and MessageService. As we have learned, in order to implement a Jupiter test against this application, we need to make the following steps:

  1. Annotate our test class with @ContextConfiguration to specify which ApplicationContext needs to be loaded.
  2. Annotate our test class with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required