History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-5375
Type: Usability Problem Usability Problem
Status: Open Open
Priority: Normal Normal
Assignee: Unassigned
Reporter: Noah Zucker
Votes: 0
Watchers: 1
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

Third-party library that redirects System.out and System.err to logger causes IDEA to abruptly halt JUnit test execution

Created: 27 Mar 08 22:36   Updated: 28 Mar 08 16:37
Component/s: Unit Testing. JUnit
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Windows XP

Build: 7,757


 Description  « Hide
Sometimes my JUnit tests do not finish when run in IDEA - they stop abruptly after tearDown() and IDEA displays the the "test interrupted" icon for the halted test case.

Stepping through code, I've found that there is an IOException occuring at the point where the JUnitStarter sends the results back to IDEA via the stdout. The problem is that the IOException throws "silently" and I can't use the debugger to get the exception message.

The problem stems from the fact that our product, TCM 6, redirects the stdout to our own logging facility. Apparently, whatever we do with stdout causes IDEA's junit integration feature to "choke." I've determined (via email with your support team) that IDEA's JUnitStarter embeds test result data in the System.out stream, resulting in this behavior.

When I run the tests using Maven 2, this behavior does not occur.

I've seen this behavior in both IDEA 5.1.2 and 7.0.3.

Below is an example stack trace (from IDEA 5.1.2) where the IOException occurs. I was using Sun Java 1.5.0_09.

java.io.PrintStream.write(PrintStream.java:421)
java.io.FilterOutputStream.write(FilterOutputStream.java:80)
com.intellij.rt.execution.junit2.segments.SegmentedOutputStream.writeNext(SegmentedOutputStream.java:61)
com.intellij.rt.execution.junit2.segments.SegmentedOutputStream.processPacket(SegmentedOutputStream.java:54)
com.intellij.rt.execution.junit2.segments.PacketWriter.sendThrough(PacketWriter.java:29)
com.intellij.rt.execution.junit2.segments.Packet.send(Packet.java:41)
com.intellij.rt.execution.junit2.TestResultsSender.endTest(TestResultsSender.java:49)
junit.framework.TestResult.endTest(TestResult.java:72)
junit.framework.TestResult.run(TestResult.java:111)
junit.framework.TestCase.run(TestCase.java:120)
junit.framework.TestSuite.runTest(TestSuite.java:230)
junit.framework.TestSuite.run(TestSuite.java:225)
junit.textui.TestRunner.doRun(TestRunner.java:121)
com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(IdeaJUnitAgent.java:58)
junit.textui.TestRunner.start(TestRunner.java:185)
com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:98)
com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)

From: Eugene Zhuravlev <jeka@intellij.com>
To: "Serge Baranov" <serge@jetbrains.com>
Date: Monday, September 3, 2007, 9:52:52 PM
Subject: [IDEA-Problem] IntelliJ abruptly halts JUnit test (problem with
sending results to IDEA)

Looks like the stream is closed, while JUntStarter is in the process of sending data. Is it possible to make sure that the stream is not closed until the starter is finished? Another option is to try to insert a delay in tearDown() or at the end of the test, so that JUnitStarter will have extra time to send its stuff.

Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

NOTE: (I scattered some Thread.sleep() calls throughout the test (both in the test cases and the tearDown()) - but it still had the same result.)



 All   Comments   Work Log   Change History      Sort Order:
Dmitry Jemerov - 28 Mar 08 10:36
Indeed, our test runner uses stdout to communicate with the main IDEA process, and we don't have any plans to rewrite our JUnit integration to use different means of communication.

Noah Zucker - 28 Mar 08 16:37
Ok, I kind of expected that answer, but just wanted to have this issue "on the books" for other users

I'll post more details in case this issue happens again. Perhaps there's a work around (other than, say, writing a custom JUnit integration plugin).