Annotation Interface GeneratorSeed


Annotation for configuring fixed generator seeds in test cases. This annotation works in conjunction with EnableGeneratorController to provide reproducible test data generation.

Features

  • Can be applied at method or class level
  • Takes precedence over system property configuration
  • Ensures consistent test data across test runs
  • Useful for debugging and reproducing test failures

Usage Examples

 // Method-level configuration
 @EnableGeneratorController
 class MyTest {
     @Test
     @GeneratorSeed(4711L)
     void shouldGenerateConsistentData() {
         var result = Generators.strings().next();
         // Will always generate the same string
     }
 }

 // Class-level configuration
 @EnableGeneratorController
 @GeneratorSeed(8042L)
 class MyReproducibleTest {
     @Test
     void allTestsUseTheSameSeed() {
         // All tests in this class use seed 8042L
     }
 }
 

Configuration Priority

  1. Method-level @GeneratorSeed
  2. Class-level @GeneratorSeed
  3. System property configuration
Author:
Oliver Wolff
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    long
     
  • Element Details

    • value

      long value
      Returns:
      the seed for the generators