@Retention(value=RUNTIME) @Target(value=METHOD) public @interface RunTimes
What is the use case of this stuff?
Some times you have legacy code which depend on some wired timing or other non-deterministic resources. Imagine a bug, where the customer tells you: "Oh, it's not a big deal. It only occurs some times. Maybe 1 or two per one hundred...". How do you reproduce that. If there is no other chance, then you must execute that edge case 100 times and check if it fails at least once. Or execute it 1000 times and check.
For this use case is this annotation: To execute a test multiple time and see how often it failed. The whole test will be green if all runs passed.
Use this annotation together with the repeater rule.
Example:
@Test
@RunTimes(10) // Runs this test ten times.
public void someTestMethod() {
// ...
}
Based on Blog post by Frank Appel.
Repeater| Modifier and Type | Required Element and Description |
|---|---|
int |
value
How many times a test must be executed.
|
Copyright © 2014 Sven Strittmatter. All Rights Reserved.