T - the type of value produced by this generator.public class Generator<T> extends Object implements Comparable<Generator<T>>
@Test
public void myTest() {
// Declare all generators at the beginning of your test, before you call .get() on any of them.
Generator<String> inputString = Generator.of(Any.string());
Generator<Integer> inputInt = Generator.of(Any.integer());
String actual = subject.someMethod(inputString.get(), inputInt.get());
// Each subsequent call to .get() will return the same value, so you can use them multiple times in your test.
assertEquals(inputString.get() + " " + inputInt.get(), actual);
}
Once you have declared the generators used by your test, you can obtain specific test values by calling the
get() method. For a given iteration, each subsequent call to get will return exactly the same value,
so it is not necessary to store the result in a separate variable. For example:
You must declare each generator used by your test before any of them are used (by calling get). This
pattern ensures that fuzzy understands how many test permutations are necessary without the need for too much
boilerplate code.
| Modifier and Type | Class and Description |
|---|---|
static class |
Generator.GeneratorBuilder |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Generator<T> o) |
boolean |
equals(Object obj) |
T |
get() |
List<StackTraceElement> |
getCreationSite() |
String |
getName() |
int |
hashCode() |
static Generator.GeneratorBuilder |
named(String name) |
static <X> Generator<X> |
of(Case<X>... cases) |
static <X> Generator<X> |
of(Subcase<X>... subcases) |
static <X> Generator<X> |
of(X... literals) |
static <X> Generator<X> |
ofCases(Case<X>... cases) |
public final String getName()
public final List<StackTraceElement> getCreationSite()
public final T get()
public static Generator.GeneratorBuilder named(String name)
@SafeVarargs public static <X> Generator<X> of(Case<X>... cases)
@SafeVarargs public static <X> Generator<X> of(X... literals)
@SafeVarargs public static <X> Generator<X> ofCases(Case<X>... cases)
@SafeVarargs public static <X> Generator<X> of(Subcase<X>... subcases)
Copyright © 2017 Redfin. All rights reserved.