【发布时间】:2015-08-13 20:51:36
【问题描述】:
当我运行 junit 测试时,我的日志如下所示:
[junit] Testcase: testSomething1 took 0.546 seconds
[junit] <statement 1>
[junit] <statement 2>
[junit] <statement 3>
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.265 sec
[junit] -----------------------Standard Output-----------------------------
[junit] <new statement 1>
[junit] <new statement 2>
[junit] <statement 1>
[junit] <statement 2>
[junit] <statement 3>
[junit] -------------------------------------------------------------------
我想删除重复的语句 1-3,但我不知道如何。
示例测试用例:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { MyConfig.class})
public class MyTestClass
{
@Autowired
private ClassIWantToTest testee;
@Test
public void testCase1()
{
boolean bool = testee.callFunc1();
Assert.assertTrue(bool);
}
}
从这个链接,我看到了如何在 Gradle 中控制这个输出,但是必须有一种方法可以用 Spring 或 Junit 本身来控制它,对吗? LINK 我开始认为我一直在找错地方。是否有 ant 设置可以在我的控制台中隐藏输出的标准输出和标准错误部分?
【问题讨论】:
-
您如何在 JUnit 测试中配置 log4j?
-
我刚刚添加了一个我的测试用例的示例。我没有对日志记录做任何特别的事情,但我得到了所有额外的输出
标签: java ant junit log4j junit4