JUnit Eclipse 显示 System.out.print() 的
我正在使用 JUnit 3 和 Eclipse 3.4。当我运行 JUnit 测试用例时,一切正常并且测试完美完成。唯一的事情是我想查看我正在运行的类的输出。所有类都具有一些输出值的基本 System.out.print() 。因此,当我运行测试时,我根本看不到任何控制台消息。当测试成功时,如何让 Eclipse 在控制台窗口中显示 System.out.print() 输出?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许其他程序也在Eclipse 的控制台上运行。请确保 Eclipse 显示 JUnit 代码的活动视图。
来自 Eclipse 帮助:
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:
jUnit 不抑制 System.out 语句。如果在测试运行期间命中该语句,则会执行该语句并写入 System.out,即在 eclipse(运行配置)中执行时的控制台窗口。
但也许您已重定向
System.out
以写入文件或日志。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.如果您想在控制台中而不是在“失败跟踪”窗口中查看堆栈跟踪(而不是 System.out),请选择“在控制台视图中显示堆栈跟踪”按钮:
点击如上所示的按钮
If you want to see the stack trace (and not System.out) in the Console, instead of in the
Failure Trace
window, select the "Show Stack Trace In Console View" button:click on the button as show above
我遇到了同样的问题,我解决了它,将 @Test 放在带有输出的功能测试之上,这解决了它......希望这可以帮助......:)
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 ... :)