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 test 5 times or 50 times or something?
Thanks.
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<Object[]> 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.
Have you tried something like this?
@Test
public void runMultipleTests() {
for (int i = 0; i < 10; i++) {
myTestMethod();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With