如何让junit的测试跑多次
Posted peachh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何让junit的测试跑多次相关的知识,希望对你有一定的参考价值。
对JUnit4可以使用下面的方法:
@RunWith(Parameterized.class)
public class RunTenTimes {
@Parameterized.Parameters
public static Object[][] data() {
return new Object[10][0]; // repeat count which you want
}
@Test
public void runsTenTimes() {
System.out.println("run");
}
}
下图是我执行了十次的结果:
对JUnit5可以使用下面的方法:
@RepeatedTest(10) // repeat count which you want
public void testMyCode() {
//your test code goes here
}
以上是关于如何让junit的测试跑多次的主要内容,如果未能解决你的问题,请参考以下文章