问题描述
正如标题所说,我正在寻找一些简单的方法来使用 Eclipse 自动连续多次运行 JUnit 4.x 测试.
Like the title says, I'm looking for some simple way to run JUnit 4.x tests several times in a row automatically using Eclipse.
一个例子是连续运行相同的测试 10 次并报告结果.
An example would be running the same test 10 times in a row and reporting back the result.
我们已经有一种复杂的方法来做到这一点,但我正在寻找一种简单的方法来做到这一点,以便我可以确定我一直试图修复的不稳定测试保持不变.
We already have a complex way of doing this but I'm looking for a simple way of doing it so that I can be sorta sure that the flaky test I've been trying to fix stays fixed.
一个理想的解决方案是我不知道的 Eclipse 插件/设置/功能.
An ideal solution would be an Eclipse plugin/setting/feature that I am unaware of.
推荐答案
使用 JUnit 5 我能够使用 @RepeatedTest 注释:
With JUnit 5 I was able to solve this using the @RepeatedTest annotation:
@RepeatedTest(10)
public void testMyCode() {
//your test code goes here
}
请注意,@Test
注释不应与 @RepeatedTest
一起使用.
Note that @Test
annotation shouldn't be used along with @RepeatedTest
.
这篇关于一遍又一遍地运行相同的junit测试的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!