Annotation Interface ElementOf


Restricts generated values to a fixed set.

Populate at least one of the type-specific arrays. Only the array that matches the annotated parameter type is used; all others are ignored. For String and wrapper types, the mutator may still emit null; add NotNull (the only supported annotation in combination with @ElementOf) to prevent that.

Example usage:


 @FuzzTest
 void fuzz(
     @ElementOf(integers = {1, 2, 3}) int option,
     @ElementOf(strings = {"one", "two"}) String label) {
   // option is always 1, 2, or 3; label is always "one" or "two".
 }
 
  • Element Details

    • bytes

      byte[] bytes
      Default:
      {}
    • shorts

      short[] shorts
      Default:
      {}
    • integers

      int[] integers
      Default:
      {}
    • longs

      long[] longs
      Default:
      {}
    • chars

      char[] chars
      Default:
      {}
    • floats

      float[] floats
      Default:
      {}
    • doubles

      double[] doubles
      Default:
      {}
    • strings

      String[] strings
      Default:
      {}