对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");
    }
}

下图是我执行了十次的结果:
如何让junit的测试跑多次

对JUnit5可以使用下面的方法:

@RepeatedTest(10) // repeat count which you want
public void testMyCode() {
    //your test code goes here
}

相关文章:

  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-01-19
  • 2021-07-26
  • 2021-11-04
猜你喜欢
  • 2021-10-21
  • 2022-12-23
  • 2021-05-09
  • 2021-12-09
  • 2021-07-17
  • 2021-07-27
  • 2021-09-29
相关资源
相似解决方案