public class Test008Timeouts extends RandomizedTest
RandomizedRunner has built-in support for enforcing test timeouts. If
a given test fails to execute in the given deadline, its thread will be
forcibly terminated (details below) and the test case will end in a failure.
A timeout can be specified in two ways. First, the standard JUnit's
Test.timeout() attribute can be used (see
standardAnnotation()). Alternatively, a more specific @link Timeout}
annotation is also provided if one needs to be explicit.
The termination of a test thread is done in several steps ranking from subtle to brute-force:
Thread.interrupt(). In many situations (I/O wait, waiting on a
monitor) this will be enough to stop the test case and return.
Thread.stop().
This should cause the test thread to throw ThreadDeath exception at
the current execution pointer and propagate up the stack.
ThreadDeath be caught and ignored as well, the
thread is declared a zombie and other tests execution is resumed with the
thread running in the background.
The information about attempts to interrupt the thread are logged to the Java's logging system along with the information about stack traces where the thread resided when interrupts were sent to it. This is typically useful in diagnosing what the thread was doing and why it couldn't be terminated. Keeping Java logging system enabled is thus strongly encouraged.
RandomizedRunner#SYSPROP_KILLATTEMPTS,
RandomizedRunner#SYSPROP_KILLWAITISO8859_1, SYSPROP_MULTIPLIER, US_ASCII, UTF16, UTF32, UTF8| Constructor and Description |
|---|
Test008Timeouts() |
| Modifier and Type | Method and Description |
|---|---|
void |
standardAnnotation() |
void |
timeoutAnnotation() |
$, $$, 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.