Dependency injection allows us to access additional data about the test using the TestReporterParameterResolver
interface.
This interface provides an instance of TestReporter
, which facilitates different methods to publish report entries for the test under execution.
Use case
We use the TestReporter
interface to print stdout
(standard output) or stderr
(standard error output) in JUnit4
.
The publishEntry()
method is used to report or print any debug messages inside our tests.
The TestReporter
interface contains one publishEntry abstract method and a couple of default publishEntry methods.
Similarly to the TestInfo
interface, we can inject the TestReporter
interface into constructors, test methods, and life cycle callbacks.
Example
The below code demonstrates the use of the TestReporter
interface.
Get hands-on with 1400+ tech skills courses.