I am using JUnit 3 with Eclipse 3.4. When I run a JUnit test case everything works fine and the test completes perfectly. Only thing is I want to see the output of the classes that I am running. All the classes have basic System.out.print() to some output values. So when I run the tests I don't see any console messages at all. How do I get Eclipse to show System.out.print() output in Console window when a test is successful?
问题:
回答1:
Maybe other program was running on the console of Eclipse too. Please ensure Eclipse displays the active view of your JUnit code.
From Eclipse Help:
Select the “Display Selected Console” command to bring the console selected from the resulting list into focus. Note: this command is only enabled if you have more than one console open.
回答2:
jUnit does not suppress System.out statements. If the statement is hit during the test run, then it is executed and writes to System.out
which is, when executed within eclipse (Run Configuration), the console window.
But maybe you've redirected System.out
to write to a file or a log.
回答3:
I had the same problem, and i solve it putting @Test above the function test with the output, and that solved it ... Hoping that this can help ... :)