public class RandomBug extends Object
Principle is to increase consistency on tests which have a random behavior. Such test is a headache because:
Compared to the @Ignore
JUnit annotation, the advantage is to provide different behaviors for different use
cases. The wanted behavior depending on whereas:
import org.nuxeo.runtime.test.runner.FeaturesRunner; import org.nuxeo.runtime.test.RandomBugRule; @RunWith(FeaturesRunner.class) public class TestSample { public static final String NXP99999 = "Some comment or description"; @Test @RandomBugRule.Repeat(issue = NXP99999, onFailure=5, onSuccess=50) public void testWhichFailsSometimes() throws Exception { assertTrue(java.lang.Math.random() > 0.2); } }
In the above example, the test fails sometimes. With the RandomBug.Repeat
annotation, it will be repeated in
case of failure up to 5 times until success. This is the default RandomBug.Mode.RELAX
mode. In order to reproduce the
bug, use the RandomBug.Mode.STRICT
mode. It will be repeated in case of success up to 50 times until failure. In
RandomBug.Mode.BYPASS
mode, the test is ignored.
You may also repeat a whole suite in the same way by annotating the class itself. You may want also want to skip some
tests, then you should then annotate the tests method with the NoRepeat
annotation.
RandomBug.Mode
Modifier and Type | Class and Description |
---|---|
static class |
RandomBug.Feature |
static class |
RandomBug.Mode
BYPASS: the test is ignored.
|
static interface |
RandomBug.Repeat
Repeat condition based on
|
class |
RandomBug.RepeatRule |
Modifier and Type | Field and Description |
---|---|
RandomBug.Mode |
DEFAULT
The default mode if
MODE_PROPERTY is not set. |
static String |
MODE_PROPERTY |
Constructor and Description |
---|
RandomBug() |
public static final String MODE_PROPERTY
public final RandomBug.Mode DEFAULT
MODE_PROPERTY
is not set.Copyright © 2015 Nuxeo SA. All rights reserved.