Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nilsga opened this issue Jul 11, 2016 · 4 comments

Comments

@nilsga
Copy link
Contributor

nilsga commented 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 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

@sbrannen
Copy link
Member

FYI: this is related to #378 and #386.

@sbrannen
Copy link
Member

sbrannen commented Jul 11, 2016

So it does not seem to be possible to use a TestReporter in conjunction with DynamicTest this way.

That's correct.

Is it possible to achieve this some other way?

No, it is unfortunately currently not possible.

Please see the discussions in #378 and #386 for further details.

@sbrannen sbrannen added this to the 5.0 M2 milestone Jul 11, 2016
@nilsga
Copy link
Contributor Author

nilsga commented Jul 11, 2016

Yes, found those issues after posting this. Thanks. Sorry about the duplication.

@sbrannen
Copy link
Member

No worries!

The use of a TestReporter in dynamic tests will be addressed in #378, so I'll close this issue as a duplicate now.

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

No branches or pull requests

2 participants