ota4j-team / opentest4j

Open Test Alliance for the JVM
Apache License 2.0
279 stars 37 forks source link

MultipleFailuresError vs. Throwable.addSuppressed #35

Closed leonard84 closed 7 years ago

leonard84 commented 7 years ago

Currently opentest4j uses Java 6 compatibility, which prevents Throwable.addSuppressed. However, Java 6 has been EOL for a very long time so switching to Java 7/8 should be considered. Which raises the question if MultipleFailuresError is still needed when further exceptions could simply be added by Throwable.addSuppressed.

marcphilipp commented 7 years ago

I think there are semantic differences between MultipleFailuresError and Throwable.addSuppressed. While the former signifies that multiple assertions failed, the latter means there was one failure and some other exceptions were suppressed during processing, e.g. tear-down.

Libraries that use opentest4j can already use Throwable.addSuppressed with e.g. AssertionFailedError if they require at least Java 7. For instance, the JUnit Jupiter engine does exactly that.

What could opentest4j offer in addition?

gaganis commented 7 years ago

I fully agree with @marcphilipp. Just adding, one of the uses cases where we utilized this was to collect errors emitted in vintage. These errors have all the same sematic importance. Using suppressed we would have a problem selecting which error is the main and which exceptions should be suppressed.

leonard84 commented 7 years ago

Ok, if the distinction of MultipleFailuresError vs Throwable.addSuppressed is that the former is used to collect multiple assertion errors and the latter is used to attach subsequent exceptions in listeners/cleanup handlers.

marcphilipp commented 7 years ago

Sounds like we're in agreement so I'm closing this issue.