Description
openedon Jul 11, 2016
I'm investigating JUnit5 for a project, and I find the concept of TestFactory
and DynamicTests
interesting for our use case. During the execution of a DynamicTest
, I would also like to report some additional information for that particular test, so I added a TestReporter
parameter to the TestFactory
method:
@TestFactory
public void createTests(TestReporter reporter) {
Stream<DynamicTest> tests = createTests(reporter);
}
Using a TestExecutionListener
, I can see that the ReportEntry
s are published, but they are all associated with the wrong TestIdentifier
. Quite obvious, when thinking about it, since the TestReporter
, once injected, is associated with the ExtensionContext
it was assigned when it was created.
So it does not seem to be possible to use a TestReporter
in conjunction with DynamicTest
this way. Is it possible to achieve this some other way? Since the TestExecutionListener
reports the correct TestIdentifier
for lifecycle events (e.g. executionFinished
) for the other DynamicTest
s, it seems like it should be possible somehow to dynamically assign the correct context to a TestReporter
.