Surefire swallows redirected test output if uncaught exceptions occur in forked SurefireBooter ----------------------------------------------------------------------------------------------
Key: SUREFIRE-432 URL: http://jira.codehaus.org/browse/SUREFIRE-432 Project: Maven Surefire Issue Type: Bug Components: process forking Affects Versions: 2.4 Environment: Maven 2.0.8, JDK 1.5.0_12, WinXP Reporter: Benjamin Bentmann Attachments: testng-execute-error.patch If Surefire - forks a test and - is configured to redirect test output to a file and - encounters an uncaught exception in its internals the tests fail (as expected) but the user does not get any information about the error, i.e. the txt files under target/surefire-reports are of zero length. This can be quite fustrating. Attached is an integration test which produces the following exception: {noformat} java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:334) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:980) Caused by: org.testng.TestNGException: Cyclic graph of methods at org.testng.internal.Graph.topologicalSort(Graph.java:117) at org.testng.internal.MethodHelper.topologicalSort(MethodHelper.java:494) at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:544) at org.testng.internal.MethodHelper.internalCollectAndOrderMethods(MethodHelper.java:77) at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:49) at org.testng.TestRunner.initMethods(TestRunner.java:337) at org.testng.TestRunner.init(TestRunner.java:216) at org.testng.TestRunner.init(TestRunner.java:178) at org.testng.TestRunner.<init>(TestRunner.java:127) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:454) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:235) at org.testng.SuiteRunner.run(SuiteRunner.java:191) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808) at org.testng.TestNG.runSuitesLocally(TestNG.java:776) at org.testng.TestNG.run(TestNG.java:701) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:64) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:136) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) ... 6 more {noformat} This uncaught exception causes abnormal completion of Surefire.run() such that reporterManager.runCompleted() never gets called. Without the call the runCompleted(), Reporter.writeFooter() gets never called, too. This means ForkingStreamConsumer.consumeLine() will never call OutputConsumer.testSetCompleted(). However, the later call would be required to properly flush the FileWriter employed by FileOutputConsumerProxy. I think what is needed is a means in SurefireBooter.fork() to flush/close the StreamConsumers after the call to CommandLineUtils.executeCommandLine() returned. -- 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