Skip to content

TestReporter does not capture the correct TestIdentifier when used with DynamicTests #393

Closed

Description

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 ReportEntrys 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 DynamicTests, it seems like it should be possible somehow to dynamically assign the correct context to a TestReporter.

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions