Search⌘ K

Registering Extensions

Discover how to register custom JUnit 5 extensions using the @ExtendWith annotation and the Java service providers mechanism. Understand the requirements for creating extensions, the use of repeatable annotations, and how to enable automatic extension detection to extend your testing options in Java.

Overview

We’ve seen JUnit 5 extensions in previous chapters, including parameter resolvers and parameterized test argument sources. These are the built-in extensions of JUnit 5. In this chapter, we’ll discuss how to create our own extensions. JUnit 5 provides the org.junit.jupiter.api.extension.Extension interface for all extensions.

An Extension is just a marker interface. Custom extensions typically implement ...