Skip to content
Advertisement

Easy way of running the same junit test over and over?

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.

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.

An ideal solution would be an Eclipse plugin/setting/feature that I am unaware of.

Advertisement

Answer

With JUnit 5 I was able to solve this using the @RepeatedTest annotation:

@RepeatedTest(10)
public void testMyCode() {
    //your test code goes here
}

Note that @Test annotation shouldn’t be used along with @RepeatedTest.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement