In Eclipse, how do I run a JUnit test case multiple times

后端 未结 4 1494
深忆病人
深忆病人 2020-12-31 19:44

I have a unit test that fails sometimes and debugging it is a pain because I don\'t know why it sometimes fails.

Is there a way inside Eclipse that I can run a JUnit

4条回答
  •  有刺的猬
    2020-12-31 19:48

    I just found the following solution which doesn't require any additional depedency (Spring is required for one of the answers you got).

    Run your test with the Parameterized runner:

    @RunWith(Parameterized.class)
    

    Then add the following method to provide a number of empty parameters equals to the number of times you want to run the test:

    @Parameterized.Parameters
    public static List data() {
        return Arrays.asList(new Object[10][0]);
    }
    

    This way you don't even have to write a loop. IntelliJ and eclipse also group the results of every iteration together.

提交回复
热议问题