This is creating test cases with a goal. For example, to increase coverage of a test suite, we need to generate test cases that exercise certain statements or follow a path.

Components

  1. Search algorithm
  2. Representation: Encoding of the problem solution
  3. Search operators: Modifications of encoded solutions
  4. Fitness function: Measure how good a candidate solution is
  5. Test Execution: Execute the tests
  6. Instrumentation: Collect traces for fitness calculations during execution

We often use Hillclimbing for our search algorithm which we cover in Fuzzing.

A fitness function can be:

  • Code coverage from JaCoCo
  • Mutation score from Pit
  • Genetic Algorithm
    • Here:
      • Generate the initial population
      • Compute fitness
      • REPEAT
        • Selection
        • Crossover
        • Mutation
        • Compute fitness
      • UNTIL population has converged