public class Test007ParameterizedTests extends RandomizedTest
Parameterized runner is
notoriously bad at giving human-readable test case names (there are several
patch proposal on github but not applied to the trunk at the time of writing
this).
RandomizedRunner has built-in support for parameters using a pair
of static-parameters provider method (factory) and a matching constructor.
The static method has to be public and annotated with ParametersFactory,
as in parameters() method below. Note the funky-looking $
and $$ method which are static varargs collector methods to avoid
explicit array constructors.
@ParametersFactory
public static Iterable
The matching class constructor must declare type-assignable parameters. Because method
arguments are not part of the Java reflection, they can be explicitly annotated using
Name annotation to provide sensible names.
The Test007ParameterizedTests(int, String)
constructor shows an example of how this looks.
If there is more than one set of parameters, method names will be postfixed with
a list of parameters and their values. An additional #num identifier will
be added to make tests unique.
ParametersFactory can be combined with other annotations such as
Repeat or Seeds as shown in paramsWithRepeatAndSeeds().
ISO8859_1, SYSPROP_MULTIPLIER, US_ASCII, UTF16, UTF32, UTF8| Constructor and Description |
|---|
Test007ParameterizedTests(int value,
String string) |
| Modifier and Type | Method and Description |
|---|---|
static Iterable<Object[]> |
parameters() |
void |
paramsWithRepeatAndSeeds() |
void |
simpleArgumentsConsumer() |
$, $$, 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.