Package de.cuioss.test.generator.junit
package de.cuioss.test.generator.junit
Provides JUnit 5 integration for the CUI test generator framework.
This package contains annotations and extensions that enable reproducible
test data generation in JUnit tests.
Core Components
EnableGeneratorController- Primary annotation for enabling generator supportGeneratorSeed- Configures fixed seeds for reproducible testsGeneratorControllerExtension- JUnit extension implementing the core functionality
Subpackages
de.cuioss.test.generator.junit.parameterized- Provides integration with JUnit 5's parameterized testing framework
Basic Usage
@EnableGeneratorController
class MyGeneratorTest {
@Test
void shouldGenerateTestData() {
var generator = new CollectionGenerator<?>(Generators.strings());
var result = generator.list(5);
assertThat(result).hasSize(5);
}
}
Test Reproduction
When a test fails, the framework provides seed information for reproduction: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'
Configuration Options
- Method-level seed:
@GeneratorSeed(4711L) - Class-level seed:
@GeneratorSeed(4711L) - System property:
-Dde.cuioss.test.generator.seed=4711
Best Practices
- Always use
@EnableGeneratorControllerat the class level - Use
@GeneratorSeedfor reproducing specific test failures - Document seeds used for specific test scenarios
- Consider using class-level seeds for related test cases
- Author:
- Oliver Wolff
- See Also:
-
ClassDescriptionJUnit 5 annotation that enables and controls the generator subsystem for test cases.JUnit 5 extension that manages test data generation by controlling generator seeds and providing detailed failure information for test reproduction.Annotation for configuring fixed generator seeds in test cases.