jUnit ErrorCollector报告重复的行

时间:2015-10-06 14:56:36

标签: java junit

我在jUnit wiki中找到了以下示例。我希望错误表应该不断报告两个错误。但有时它会报告第二次错误两次。任何解释?

    public class ErrorCollectorRuleTest {
    @Rule
    public ErrorCollector collector= new ErrorCollector();

    @Test
    public void example() {
        collector.addError(new Throwable("first thing went wrong"));
        collector.addError(new Throwable("second thing went wrong"));
        System.out.println("Completed");
    }
}

输出:

Completed
java.lang.Throwable: first thing went wrong
java.lang.Throwable: second thing went wrong
java.lang.Throwable: second thing went wrong

1 个答案:

答案 0 :(得分:2)

我认为这是一个IntelliJ Idea漏洞。见https://github.com/junit-team/junit/issues/1104