Annotation Interface Repeated
As a matter of practice, no test should ever be committed into source control with this
annotation. It is only a tool for diagnosing non-deterministic test failures on the developer's
workstation. For example, suppose testSomeMethod
fails every other Tuesday on the CI
system, but never seems to fail on the developer's workstation. It might help to repeat a test
100 times, including its set-up and tear-down, in a single test run. To do this, the developer
can temporarily add the @Repeated(100)
annotation, and then run the test from their IDE.
@Test @Repeated(100) public void testSomeMethod() { SomeClass obj = new SomeClass(); obj.someMethod(); assertEquals(3, obj.getSomeState()); }
The number of repetitions can be adjusted depending on the desired level of assurance. If the failure is truly due to timing, and not some other condition unique to the CI system, then it will likely fail within 100 repetitions. Once the code is fixed, and the test passes for the desired number of repetitions, the annotation should be removed before the changes are committed.
-
Required Element Summary
Modifier and TypeRequired ElementDescriptionint
The number of times to repeat the test, must be positive
-
Element Details
-
value
int valueThe number of times to repeat the test, must be positive- Returns:
- the count
-