TestInfo parameter
Understand how to use the TestInfo parameter in JUnit 5 to inject metadata into test constructors and methods. This lesson helps you explore Dependency Injection with TestInfo, enabling access to test display names, classes, methods, and associated tags for more informative tests.
We'll cover the following...
ParameterResolver
In previous JUnit versions, there was limited/no support to allow parameters in test constructors or methods. One of the major changes in JUnit 5 Jupiter was that both test constructors and test methods are now allowed to have parameters. These parameters provide metadata to constructors and test methods. Thus, allows for greater flexibility and enables Dependency Injection for test methods and constructors.
In Junit 5, there is an interface in org.junit.jupiter.api.extension package by name, ParameterResolver. This interface defines the API for test extensions that wish to dynamically ...