In the real world, extensions typically implement several of the previously explained extension points. For example, SpringExtension (explained in detail in chapter 5, Integration of JUnit 5 with external frameworks) implements the extensions points BeforeAllCallback, TestInstancePostProcessor, ParameterResolver, among others. The following snippet provides the structure of SpringExtension:
package org.springframework.test.context.junit.jupiter;
import org.junit.jupiter.api.extension.*;
public class SpringExtension implements BeforeAllCallback,
AfterAllCallback,
TestInstancePostProcessor, BeforeEachCallback, AfterEachCallback,
BeforeTestExecutionCallback, AfterTestExecutionCallback,
ParameterResolver {
@Override
public void afterTestExecution(TestExtensionContext context)
throws Exception {
// implementation
}
// Rest of methods
}
A list of existing JUnit 5 extensions (for example, Spring, Selenium, Docker, and others) is maintained by the community in the wiki located in the GitHub site of the JUnit 5 team: https://github.com/junit-team/junit5/wiki/Third-party-Extensions. Some of them are also detailed in chapter 5, Integration of JUnit 5 with external frameworks.