杂乱的junit日志,为什么会重复语句?
Cluttered junit logs, why does it repeat statements?
当我 运行 我的 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);
}
}
从这个 link 中,我看到了如何在 Gradle 中控制这个输出,但是必须有一种方法可以用 Spring 或 Junit 本身来控制它,对吗? LINK 我开始觉得自己一直找错地方了。是否有 ant 设置可以在我的控制台中隐藏输出的标准输出和标准错误部分?
我对 junit 不是很熟悉,但看看日志级别是否未设置。然后它可能默认为 DEBUG,这意味着您将获得一切。如果是这样,请尝试将日志级别更改为 WARN。
所以这对我来说很奇怪,但我需要在我的 ant junit 任务上设置 showoutput="false" 。我的格式化程序嵌套元素为我提供了我需要的所有输出。通过同时使用 showoutput="true" 和格式化程序嵌套元素,我将输出打印了两次到我的控制台 :(
我从这个堆栈溢出问题中得出了这个结论:LINK
当我 运行 我的 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);
}
}
从这个 link 中,我看到了如何在 Gradle 中控制这个输出,但是必须有一种方法可以用 Spring 或 Junit 本身来控制它,对吗? LINK 我开始觉得自己一直找错地方了。是否有 ant 设置可以在我的控制台中隐藏输出的标准输出和标准错误部分?
我对 junit 不是很熟悉,但看看日志级别是否未设置。然后它可能默认为 DEBUG,这意味着您将获得一切。如果是这样,请尝试将日志级别更改为 WARN。
所以这对我来说很奇怪,但我需要在我的 ant junit 任务上设置 showoutput="false" 。我的格式化程序嵌套元素为我提供了我需要的所有输出。通过同时使用 showoutput="true" 和格式化程序嵌套元素,我将输出打印了两次到我的控制台 :(
我从这个堆栈溢出问题中得出了这个结论:LINK