Class JUnit5FuzzConfig

java.lang.Object
edu.berkeley.cs.jqf.junit5.JUnit5FuzzConfig

public final class JUnit5FuzzConfig extends Object
Reads a @FuzzTest's run configuration from its annotation, system properties, the environment, and any externally installed guidance.

This is the single place that decides between the two modes (regression and fuzzing), builds the Guidance for a fuzzing campaign, and enumerates the inputs replayed by a regression run.

  • Method Details

    • from

      public static JUnit5FuzzConfig from(Class<?> testClass, Method method)
      Reads the configuration for one fuzz-test method.
      Parameters:
      testClass - the test class
      method - the @FuzzTest method
      Returns:
      the configuration
    • installGuidance

      public static void installGuidance(Guidance guidance)
      Installs a guidance to drive every subsequent @FuzzTest run.
      Parameters:
      guidance - the guidance to install
    • installedGuidance

      public static Guidance installedGuidance()
      Returns the externally installed guidance, or null if none is set.
      Returns:
      the installed guidance, or null
    • clearInstalledGuidance

      public static void clearInstalledGuidance()
      Clears any externally installed guidance.
    • isFuzzingMode

      public boolean isFuzzingMode()
      Reports whether this run should fuzz rather than replay a bounded regression.

      Fuzzing is selected by an installed guidance, the jqf.fuzz system property, the JQF_FUZZ environment variable, or a repro input.

      Returns:
      true for a fuzzing campaign, false for regression
    • createGuidance

      public Guidance createGuidance() throws IOException
      Builds the guidance for a fuzzing campaign.
      Returns:
      an installed, repro, or fresh Zest guidance
      Throws:
      IOException - if the guidance's output directory cannot be prepared
    • regressionInputs

      public List<JUnit5FuzzConfig.NamedInput> regressionInputs()
      Enumerates the inputs replayed by a regression run: the saved corpus from a previous fuzzing run, any seeds, and one empty (all-zero) input.
      Returns:
      the regression inputs, in replay order
    • outputDirectory

      public File outputDirectory()
      Returns the output directory for this method's fuzzing results, <base>/<FQCN>/<method> where the base is target/fuzz-results unless overridden by the jqf.fuzz.out system property.
      Returns:
      the output directory