Class JUnit5FuzzRunner

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

public final class JUnit5FuzzRunner extends Object
The reusable JUnit 5 fuzzing entry point.

It wires the framework-independent FuzzRunner to the JUnit 5 adapters: a Junit5TrialExecutor for trial execution and a Junit5ResultClassifier for outcome classification. The argument generator is resolved separately (so it stays pluggable). Both the Jupiter extension and integration tests use this class.

  • Method Details

    • resolveArguments

      public static ArgumentsGenerator resolveArguments(Class<?> testClass, Method testMethod)
      Resolves the argument generator for a fuzz-test method.

      If the method's FuzzTest.arguments() names a concrete factory, that factory is used; otherwise the provider is discovered through ServiceLoader. Methods without a @FuzzTest annotation (for example a JUnit 4 @Fuzz method reused by an integration test) always fall back to ServiceLoader.

      Parameters:
      testClass - the test class
      testMethod - the fuzz-test method
      Returns:
      a generator bound to the method
      Throws:
      IllegalStateException - if no provider is available
    • decode

      public static Object[] decode(ArgumentsGenerator generator, InputStream input)
      Decodes one input into the arguments for a single trial.
      Parameters:
      generator - the argument generator
      input - the raw bytes of one saved or seed input
      Returns:
      the decoded arguments
    • fuzz

      public static FuzzResult fuzz(Class<?> testClass, Method method, Guidance guidance, ArgumentsGenerator arguments)
      Runs a full fuzzing campaign for a fuzz-test method under the given guidance.

      The guidance's instrumentation callback is registered, and any tracer left over from a previous campaign in this JVM is dropped, before snooping starts, mirroring FuzzRunner.run(Class, String, Guidance).

      Parameters:
      testClass - the test class
      method - the fuzz-test method
      guidance - the fuzzing guidance
      arguments - the argument generator
      Returns:
      the campaign result