Package de.cuioss.test.generator.junit
Annotation Interface EnableGeneratorController
@Retention(RUNTIME)
@Target(TYPE)
@ExtendWith(GeneratorControllerExtension.class)
public @interface EnableGeneratorController
JUnit 5 annotation that enables and controls the generator subsystem for test cases.
This annotation provides reproducible test data generation by managing generator seeds
and providing detailed failure information for test reproduction.
Features
- Controls generator seed initialization
- Provides detailed failure information for test reproduction
- Supports fixed seeds via
GeneratorSeedannotation - Enables system property configuration for seeds
Usage
@EnableGeneratorController
class MyGeneratorTest {
@Test
void shouldGenerateData() {
var generator = new CollectionGenerator<>(Generators.strings());
var result = generator.list(5);
assertThat(result).hasSize(5);
}
}
Test Reproduction
On test failure, the extension provides detailed information about the generator seed:GeneratorController seed was 4711L. Use a fixed seed by applying @GeneratorSeed(4711L) for the method/class, or by using the system property '-Dde.cuioss.test.generator.seed=4711'
Seed Configuration Options
- Method-level:
@GeneratorSeed(4711L) - Class-level:
@GeneratorSeed(4711L) - System Property:
-Dde.cuioss.test.generator.seed=4711
- Author:
- Oliver Wolff
- See Also: