Add ITs for AfterAll/AfterClass teardown failure#3338
Add ITs for AfterAll/AfterClass teardown failure#3338XN137 wants to merge 2 commits intoapache:masterfrom
Conversation
|
@olamy as requested in #3329 (comment) i am adding ITs to document the current (faulty?) behavior |
bf63960 to
76fd2bb
Compare
Add integration tests exposing broken surefire behavior when JUnit 4 `@AfterClass` or JUnit 5 `@AfterAll` methods always throw. The tests document the following bugs on master: - XML report has `errors="0"` despite an `<error>` element in a testcase - The teardown error is misclassified as a flake (`flakes="1"`) - With `rerunFailingTestsCount`, the build passes green because the deterministic teardown failure is swallowed as a flake - Passing test methods are needlessly re-executed (`rerunCount + 1` times)
76fd2bb to
fdc1b42
Compare
|
This is arguable. If the test method passes, I'm not sure a tearDown failure should be marked as failed. The test ran. The test passed. And then something else happened. |
|
I agree that it's arguable what the exact behavior should be but assuming we take your viewpoint, then in the case with another viewpoint could be: |
elharo
left a comment
There was a problem hiding this comment.
As I said, it's arguable. There are reasonable cases to be made on both sides here. Continuing to think about this, I think errors=0 is true and should not be changed. The test passed. That much is correct.
The test is not flaky (unless the tearDown failure is flaky) so counting this as a flake and rerunning the test is a bug.
And probably there should be a separate way to indicate to the user that tearDown failed (tearDownErrors = 1 or something along those lines) but if we mix this up with test failures then the dev could be looking in the wrong place to debug the failure
|
i have now removed all code comments stating what is and isnt a bug, so the tests now only encode the current behavior on the master branch. @elharo were you looking for any other kind of changes? |
|
also i ran the ITs against older releases of surefire to compare current behavior to previous versions. (note that i had to delete the when going to 3.5.5 for junit4: but we have to change junit4 assertion to: when going to 3.5.5 for junit5: when going to 3.5.4 for junit4: when going to 3.5.4 for junit5: so as far as i can tell 3.5.4 reported class teardown exceptions as errors and 3.5.5 stopped doing that. but b4a53de caught my eye and i confirmed locally that if i check out 3.5.5 and revert that change, the reporting of teardown issues goes back to "normal" (i.e. 3.5.4 and before). also only junit5 used to rerun test methods for |
Add integration tests exposing broken surefire behavior when JUnit 4
@AfterClassor JUnit 5@AfterAllmethods always throw. The testsdocument the following bugs on master:
errors="0"despite an<error>element in a testcaseflakes="1")rerunFailingTestsCount, the build passes green because thedeterministic teardown failure is swallowed as a flake
rerunCount + 1times)