Package randoop.test

Class ValidityCheckingGenerator

java.lang.Object
randoop.test.TestCheckGenerator
randoop.test.ValidityCheckingGenerator

public class ValidityCheckingGenerator extends TestCheckGenerator
A ValidityCheckingGenerator checks for occurrences of exceptions that have been tagged as invalid behaviors. Also, either ignores or reports flaky test sequences --- an input sequence that throws an exception in a longer test sequence, despite having run normally by itself. Ignored flaky sequences are classified as invalid. Flaky occurrences of OutOfMemoryError or StackOverflowError are always treated as invalid.
  • Field Details

    • throwExceptionOnFlakyTest

      private boolean throwExceptionOnFlakyTest
      If true, report flaky tests by throwing an exception.
  • Constructor Details

    • ValidityCheckingGenerator

      public ValidityCheckingGenerator(boolean throwExceptionOnFlakyTest)
      Creates an object that looks for invalid exceptions.
      Parameters:
      throwExceptionOnFlakyTest - a flag indicating whether to report flaky tests by throwing an exception
  • Method Details

    • generateTestChecks

      public InvalidChecks generateTestChecks(ExecutableSequence eseq)
      Generate a TestChecks object for the executed sequence eseq based on the criteria of this generator.

      Checks validity of a test sequence and creates a InvalidChecks object containing a InvalidChecks for the first invalid exception encountered, if any. There are three possible outcomes:

      • An exception is seen before the last statement:
        • If throwExceptionOnFlakyTest is true and the exception is not OutOfMemoryError or StackOverflowError, throw an exception.
        • Otherwise, the sequence is invalid.
      • An exception is seen on the last statement:
        • if the exception is classified as invalid, the sequence is invalid.
        • otherwise, the returned InvalidChecks is empty (the sequence is valid).
      • Otherwise, the returned InvalidChecks is empty (the sequence is valid).
      Specified by:
      generateTestChecks in class TestCheckGenerator
      Parameters:
      eseq - the sequence for which checks are generated
      Returns:
      a possibly-empty InvalidChecks object for sequence
      Throws:
      Error - if throwExceptionOnFlakyTest==true and exception encountered before last statement of sequence