public class Test006RepeatingTests extends RandomizedTest
Test005RecoveringRandomSeed we presented
Randomness contexts and how they are derived from a master seed. Once
you know a certain test case fails it is usually beneficial to immediately
check if it always fails on a given seed (which means there is a
deterministic failure scenario). A simple way to do so would be to re-run a
test case a few times. The same effect can be achieved by adding a
Repeat annotation with Repeat.useConstantSeed() set to
false attribute as shown in the method repeatFailure()
below.
@Note how the seed is fixed usingRepeat(iterations = 5, useConstantSeed = true) @Seed("f00ddead") @Testpublic void repeatFailure() { //...
Seed annotation (on the
method) rather than on the master. This ensures the method's context is
pinned to that value, but the master is still random. If you have
BeforeClass hooks that depend on randomness you should use
suite-level Seed annotation and pin the master seed instead.
You can also set Repeat.useConstantSeed() to false and
then every iteration of the test method will have a pseudo-random context derived
from the first one (pinned or not). This can be useful to tell how frequently
a given test case fails for a random seed. For halfAndHalf() method
about 50% of iterations will fail.
ISO8859_1, SYSPROP_MULTIPLIER, US_ASCII, UTF16, UTF32, UTF8| Constructor and Description |
|---|
Test006RepeatingTests() |
| Modifier and Type | Method and Description |
|---|---|
void |
halfAndHalf() |
void |
repeatFailure() |
$, $$, assumeFalse, assumeFalse, assumeNoException, assumeNoException, assumeNotNull, assumeTrue, assumeTrue, atLeast, atMost, between, closeAfterSuite, closeAfterTest, frequently, getContext, getRandom, globalTempDir, isNightly, iterations, multiplier, newServerSocket, newTempDir, newTempDir, newTempFile, newTempFile, randomAsciiOfLength, randomAsciiOfLengthBetween, randomBoolean, randomByte, randomDouble, randomFloat, randomFrom, randomFrom, randomGaussian, randomInt, randomInt, randomIntBetween, randomLocale, randomLong, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, rarely, scaledRandomIntBetween, sleep, systemPropertyAsBoolean, systemPropertyAsDouble, systemPropertyAsFloat, systemPropertyAsInt, systemPropertyAsLongassertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, failCopyright © 2011-2012 Carrot Search s.c.. All Rights Reserved.