[英]How to print inside unit tests in Java?
I have written a few unit tests using JUnit and am running them via the main method using a test suite.我已经使用 JUnit 编写了一些单元测试,并使用测试套件通过 main 方法运行它们。 However, I noticed that the System.out.print statements that I put inside my unit test methods are not outputting to the console like I expected.
但是,我注意到我放在单元测试方法中的 System.out.print 语句没有像我预期的那样输出到控制台。
Is there a simple way to achieve this behavior?有没有一种简单的方法来实现这种行为?
Just use System.out.println
normally.正常使用
System.out.println
。 It will print when you run the test.它会在您运行测试时打印。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.