junit有时会因超时错误而失败,即使远低于限制也是如此

时间:2012-11-13 16:44:50

标签: ant junit cobertura

我已经设置了一个Ant构建脚本来运行Cobertura的单元测试。我在“junit”任务中有一个“超时”属性为“10000”。

我已多次测试运行我的单元测试。出于某种原因,当我在没有运行一段时间之后第一次运行它时(就像早上的第一件事),我经常看到每个测试用例都失败了:

    Testsuite: ...
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

Testcase: null took 0.109 sec
    Caused an ERROR
Timeout occurred. Please note the time in the report does not reflect the time until the timeout.
junit.framework.AssertionFailedError: Timeout occurred. Please note the time in the report does not reflect the time until the timeout.

每次发生这种情况,我只需重新运行命令行,一切正常。当它像这样失败时,它会在启动之前延迟一点,但它肯定不是10秒。

我该怎么做才能防止这种情况发生?当我从命令行手动运行它时会发生一件事,但是当我将这个设置从CI服务器运行时,这将是另一回事,其中无关的故障将更加烦人。

1 个答案:

答案 0 :(得分:0)

我想我打算称之为无意义。问题的一部分是Cobertura目前正在打印大量的调试输出,我猜这是导致问题的原因。当我添加'forkmode =“once”'时,它有所帮助。他们正致力于为Cobertura增加“安静模式”,这将有助于进一步发展。

相关问题