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

NPE problem will happen if you set testng status to fail at afterInvocation method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.13, 2.14, 2.15, 2.16, 2.17
    • 2.18
    • Maven Surefire Plugin
    • None
    • Maven 3.1.1, TestNG (Try different version), Maven suirefire plugin 2.11~2.17

    Description

      In our test program, we have some soft assert, which require us set the test result to false at afterInovcation (IInvokedMethodListener) method, after we did that, surefire plugin will throw a NPE exception, the stacktrace looks like this:

      Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.61 sec <<< FAILURE!
      test1(com.surefire.SimpleTest)  Time elapsed: 0.044 sec  <<< FAILURE!
      java.lang.NullPointerException: null
      	at org.apache.maven.surefire.report.SmartStackTraceParser.<init>(SmartStackTraceParser.java:56)
      	at org.apache.maven.surefire.report.PojoStackTraceWriter.smartTrimmedStackTrace(PojoStackTraceWriter.java:60)
      	at org.apache.maven.surefire.booter.ForkingRunListener.encode(ForkingRunListener.java:328)
      	at org.apache.maven.surefire.booter.ForkingRunListener.encode(ForkingRunListener.java:312)
      	at org.apache.maven.surefire.booter.ForkingRunListener.toString(ForkingRunListener.java:258)
      	at org.apache.maven.surefire.booter.ForkingRunListener.testFailed(ForkingRunListener.java:137)
      	at org.apache.maven.surefire.testng.TestNGReporter.onTestFailure(TestNGReporter.java:105)
      	at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895)
      	at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
      	at org.testng.internal.Invoker.invokeMethod(Invoker.java:778)
      	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      	at org.testng.TestRunner.privateRun(TestRunner.java:767)
      	at org.testng.TestRunner.run(TestRunner.java:617)
      	at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
      	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
      	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
      	at org.testng.SuiteRunner.run(SuiteRunner.java:254)
      	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
      	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
      	at org.testng.TestNG.run(TestNG.java:1057)
      	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
      	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:126)
      	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110)
      	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:117)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
      	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
      	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
      

      I will attach a simple project to reproduce this problem.

      Attachments

        1. target.zip
          73 kB
          tim wu

        Activity

          People

            agudian Andreas Gudian
            wutingbupt tim wu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: