[ http://jira.codehaus.org/browse/SUREFIRE-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_107549 ]
Gerhard Langs commented on SUREFIRE-157: ---------------------------------------- Re-Implemented the TestNGReporter method below based on the trunk source code (not submitted to svn). Should now report Before* Errors: public void onFinish(ITestContext context) { boolean failureSeen = false; IResultMap F_rmap = context.getFailedConfigurations(); Iterator F_rset = F_rmap.getAllResults().iterator(); while (F_rset.hasNext()) { ITestResult F_tres = (ITestResult) F_rset.next(); onTestFailure(F_tres); failureSeen = true; } String rawString = bundle.getString( failureSeen ? "executeException" : "testSetCompletedNormally" ); ReportEntry report = new ReportEntry(source, context.getName(), groupString(context.getIncludedGroups(), null), rawString); reportManager.testSetCompleted(report); reportManager.reset(); } > Surefire Plugin fails to handle exception thrown from TestNG @BeforeTest > method > ------------------------------------------------------------------------------- > > Key: SUREFIRE-157 > URL: http://jira.codehaus.org/browse/SUREFIRE-157 > Project: Maven Surefire > Issue Type: Bug > Components: TestNG support > Affects Versions: 2.0 (2.2 plugin), 2.3 > Environment: Windows XP, JDK 1.5, Maven 2.0.4, TestNG 5.1 > Reporter: Manish Shah > Fix For: 2.4 > > > Create a TestNG test with a method as follows: > @BeforeTest > public void beforeTest() { > throw new RuntimeException("Simulate an exception from a beforeTest > method"); > } > When surefire attempts to run this test, the plugin fails with the following > stack trace: > org.apache.maven.surefire.booter.SurefireExecutionException: null; nested > exception is java.lang.NullPointerException: n > ull > java.lang.NullPointerException > at > org.apache.maven.surefire.report.AbstractTextReporter.testFailed(AbstractTextReporter.java:106) > at > org.apache.maven.surefire.report.ReporterManager.testFailed(ReporterManager.java:299) > at > org.apache.maven.surefire.report.ReporterManager.testFailed(ReporterManager.java:281) > at > org.apache.maven.surefire.testng.TestNGReporter.onTestFailure(TestNGReporter.java:97) > at org.testng.internal.Invoker.runTestListeners(Invoker.java:1164) > at org.testng.internal.Invoker.runTestListeners(Invoker.java:1149) > at > org.testng.internal.Invoker.handleConfigurationFailure(Invoker.java:191) > at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:170) > at org.testng.SuiteRunner.privateRun(SuiteRunner.java:236) > at org.testng.SuiteRunner.run(SuiteRunner.java:145) > at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901) > at org.testng.TestNG.runSuitesLocally(TestNG.java:863) > at > org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:64) > at > org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75) > at org.apache.maven.surefire.Surefire.run(Surefire.java:129) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at > org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225) > at > org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira