ErrorCollector are not reported as a list of failures as shown below. Test code for this issue is provide in the javadocs for the JUnit 4 ErrorCollector at http://junit.org/junit4/javadoc/latest/org/junit/rules/ErrorCollector.html.│ ├─ example.testrule.ErrorCollectorVintageDemo
│ │ ├─ example ✘
Expected: not a string containing "ERROR!"
but: was "ERROR! - something is broke"
ErrorCollector should be displayed. The output below shows how the same test executed via the JUnit 4 directly produces the expected three results.java.lang.Throwable: first thing went wrong
java.lang.Throwable: second thing went wrong
java.lang.AssertionError:
Expected: not a string containing "ERROR!"
but: was "ERROR! - something is broke"
Thanks for reporting! This is indeed a bug in the Vintage engine. JUnit 4 special-cases MultipleFailureException and calls RunListener#testFailure() once for each failure. With the Platform's EngineExecutionListener it's not possible to report multiple failures separately. Thus, I see the following options:
Throwable#addSuppressed on the first exception with all remaining exceptions.org.junit.runners.model.MultipleFailureException with all exceptions.org.opentest4j.MultipleFailuresError with all exceptions. However, it can currently only contain AssertionErrors. So we would need to change that.Opinions?
My opinion?
I think I'm more in favor of (3) above as it uses the MultipleFailuresError directly which is how the equivalent code in JUnit 5 works. I had noted that as I was writing the vintage and jupiter demo code for ErrorCollector that I realized the example in the javadocs was very contrived. I actually like how the JUnit 5 code works better so I'd suggest the following:
Throwable create an AssertionError setting the message to the message of the offending Throwable and adding the throwable as the cause.AsssertionErrors (whether directly reported or created from Throwables) to the MultipleFailuresErrorThat's essentially what the code I've committed for the '''ErrorCollectorJupiterDemo``` (a9889db) is going to produce anyway.
Hello all!
This issue has a pretty straightforward spec, even though @marcphillips comment hints the implementation to be more interesting. I was watching for something that I could maybe try tackling.
Is this up for grabs?
Thanks
Giorgos
Thanks for the offer! Please wait until we've decided how to implement it, though.
Team decision:
org.opentest4j.MultipleFailuresError to support Throwable instead of AssertionErrorThanks @marcphilipp for the implementation details.
I am starting to look into this. :)