Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1172

Incompatibility with MultipleFailureException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • junit 4.12
      maven-surefire-plugin 2.18.1

    Description

      Given this test:

      public class MyTest {
      
          @Rule public ErrorCollector errorCollector = new ErrorCollector();
      
          @Test
          public void test() {
              errorCollector.checkThat("asd", CoreMatchers.startsWith("B"));
              errorCollector.checkThat("asd", CoreMatchers.startsWith("C"));
          }
      }
      

      mvn clean test will produce the following output:

      -------------------------------------------------------
       T E S T S
      -------------------------------------------------------
      Running MyTest
      Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.089 sec <<< FAILURE!
      test(MyTest)  Time elapsed: 0.019 sec  <<< FAILURE!
      java.lang.AssertionError:
      Expected: a string starting with "B"
           but: was "asd"
      	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
      	at org.junit.Assert.assertThat(Assert.java:956)
      	at org.junit.rules.ErrorCollector$1.call(ErrorCollector.java:65)
      	at org.junit.rules.ErrorCollector.checkSucceeds(ErrorCollector.java:78)
      	at org.junit.rules.ErrorCollector.checkThat(ErrorCollector.java:63)
      	at org.junit.rules.ErrorCollector.checkThat(ErrorCollector.java:54)
      	at MyTest.test(MyTest.java:19)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.rules.Verifier$1.evaluate(Verifier.java:35)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      
      test(MyTest)  Time elapsed: 0.02 sec  <<< FAILURE!
      java.lang.AssertionError:
      Expected: a string starting with "C"
           but: was "asd"
      	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
      	at org.junit.Assert.assertThat(Assert.java:956)
      	at org.junit.rules.ErrorCollector$1.call(ErrorCollector.java:65)
      	at org.junit.rules.ErrorCollector.checkSucceeds(ErrorCollector.java:78)
      	at org.junit.rules.ErrorCollector.checkThat(ErrorCollector.java:63)
      	at org.junit.rules.ErrorCollector.checkThat(ErrorCollector.java:54)
      	at MyTest.test(MyTest.java:20)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.rules.Verifier$1.evaluate(Verifier.java:35)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      
      
      Results :
      
      Failed tests:   test(MyTest): (..)
        test(MyTest): (..)
      
      Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
      

      Actual: "Tests run: 2, Failures: 2, Errors: 0, Skipped: 0"
      Expected: "Test run: 1, Failures: 2"

      You may be interested in having a look at this snippet:
      https://github.com/junit-team/junit/blob/master/src/main/java/org/junit/internal/runners/model/EachTestNotifier.java#L21

      Thanks

      Attachments

        Issue Links

          Activity

            People

              tibordigana Tibor Digana
              alb-i986 Alberto Scotto
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: