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

Subpackages

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

  1. Method-level seed: @GeneratorSeed(4711L)
  2. Class-level seed: @GeneratorSeed(4711L)
  3. System property: -Dde.cuioss.test.generator.seed=4711

Best Practices

  • Always use @EnableGeneratorController at the class level
  • Use @GeneratorSeed for 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: