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

Empty report when beforeAll is failing #2537

Closed
dubilyer opened this issue Jan 19, 2021 · 9 comments · Fixed by #2542
Closed

Empty report when beforeAll is failing #2537

dubilyer opened this issue Jan 19, 2021 · 9 comments · Fixed by #2542

Comments

@dubilyer
Copy link

dubilyer commented Jan 19, 2021

Steps to reproduce

  1. Create a testClass with parameterized tests only;
  2. Create a beforeAll method throwing NPE;
  3. Register LegacyXmlReportGeneratingListener.

Because we have:

  void writeXmlReport(TestIdentifier testIdentifier, Writer out) throws XMLStreamException {
      List<TestIdentifier> tests = (List)this.reportData.getTestPlan().getDescendants(testIdentifier).stream().filter(TestIdentifier::isTest).collect(Collectors.toList());
      this.writeXmlReport(testIdentifier, tests, out);
  }

in XmlReportWriter

and all skipped tests are containers (isTest() = false), we have a completely clean xml report with no way to understand, that beforeAll failed and tests were skipped.

Junit version is 5.5.1, platform 1.7.1

@marcphilipp
Copy link
Member

Very good point, we should also included failed containers.

@marcphilipp marcphilipp added this to the 5.7.1 milestone Jan 19, 2021
@marcphilipp marcphilipp changed the title Empty report when beforAll is failing Empty report when beforeAll is failing Jan 22, 2021
@marcphilipp marcphilipp self-assigned this Jan 25, 2021
@marcphilipp
Copy link
Member

@dubilyer Are you sure those tests fail in a @BeforeAll method? If they did, this method would cause the NPE to be reported for each contained test identifier:

Optional<TestExecutionResult> getResult(TestIdentifier testIdentifier) {
if (this.finishedTests.containsKey(testIdentifier)) {
return Optional.of(this.finishedTests.get(testIdentifier));
}
Optional<TestIdentifier> parent = this.testPlan.getParent(testIdentifier);
Optional<TestIdentifier> ancestor = findAncestor(parent, this.finishedTests::containsKey);
if (ancestor.isPresent()) {
TestExecutionResult result = this.finishedTests.get(ancestor.get());
if (result.getStatus() != SUCCESSFUL) {
return Optional.of(result);
}
}
return Optional.empty();
}

@dubilyer
Copy link
Author

dubilyer commented Jan 26, 2021 via email

marcphilipp added a commit that referenced this issue Jan 31, 2021
Prior to this commit, failing containers were only reported in case they
contained at least one test. However, for example for a parameterized
Jupiter tests and an exception in a `@BeforeAll` method, that led to
failures being silently swallowed. Now, in addition to tests, leaf
nodes of the test tree are always included in the XML report, even if
they are containers, not tests.

Fixes #2537.
marcphilipp added a commit that referenced this issue Feb 1, 2021
Prior to this commit, failing containers were only reported in case they
contained at least one test. However, for example for a parameterized
Jupiter tests and an exception in a `@BeforeAll` method, that led to
failures being silently swallowed. Now, in addition to tests, leaf
nodes of the test tree are always included in the XML report, even if
they are containers, not tests.

Moreover, failures on the container level that occurred after their
children had been executed were not reported, e.g. when an exception
was thrown from a Jupiter `@AfterAll` method. Now such failures cause
the contained tests to be reported as failed.

Fixes #2537.
marcphilipp added a commit that referenced this issue Feb 1, 2021
Prior to this commit, failing containers were only reported in case they
contained at least one test. However, for example for a parameterized
Jupiter tests and an exception in a `@BeforeAll` method, that led to
failures being silently swallowed. Now, in addition to tests, leaf
nodes of the test tree are always included in the XML report, even if
they are containers, not tests.

Moreover, failures on the container level that occurred after their
children had been executed were not reported, e.g. when an exception
was thrown from a Jupiter `@AfterAll` method. Now such failures cause
the contained tests to be reported as failed.

Fixes #2537.
@marcphilipp
Copy link
Member

I think I figured it out. 🙂

@dubilyer Do you have time to verify my change with your project against the latest 5.7.1-SNAPSHOT version from https://oss.sonatype.org/content/repositories/snapshots/?

@dubilyer
Copy link
Author

dubilyer commented Feb 2, 2021

I will check and update. Thanks a lot!

mpkorstanje pushed a commit to mpkorstanje/junit5 that referenced this issue Feb 6, 2021
Prior to this commit, failing containers were only reported in case they
contained at least one test. However, for example for a parameterized
Jupiter tests and an exception in a `@BeforeAll` method, that led to
failures being silently swallowed. Now, in addition to tests, leaf
nodes of the test tree are always included in the XML report, even if
they are containers, not tests.

Moreover, failures on the container level that occurred after their
children had been executed were not reported, e.g. when an exception
was thrown from a Jupiter `@AfterAll` method. Now such failures cause
the contained tests to be reported as failed.

Fixes junit-team#2537.
@dubilyer
Copy link
Author

Cannot get a platform dependency with this version.

@marcphilipp
Copy link
Member

For platform, it would be 1.7.1-SNAPSHOT. However, we've released 1.7.1/5.7.1 in the meantime.

@dubilyer
Copy link
Author

Issue resolved! Thanks a lot. Waiting for release version :)

@sbrannen
Copy link
Member

Issue resolved! Thanks a lot. Waiting for release version :)

@dubilyer, it has already been released: https://github.com/junit-team/junit5/releases/tag/r5.7.1

runningcode pushed a commit to runningcode/junit5 that referenced this issue Feb 15, 2023
Prior to this commit, failing containers were only reported in case they
contained at least one test. However, for example for a parameterized
Jupiter tests and an exception in a `@BeforeAll` method, that led to
failures being silently swallowed. Now, in addition to tests, leaf
nodes of the test tree are always included in the XML report, even if
they are containers, not tests.

Moreover, failures on the container level that occurred after their
children had been executed were not reported, e.g. when an exception
was thrown from a Jupiter `@AfterAll` method. Now such failures cause
the contained tests to be reported as failed.

Fixes junit-team#2537.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants