Package randoop.test

Class ExpectedExceptionCheckGen

java.lang.Object
randoop.test.ExpectedExceptionCheckGen

public class ExpectedExceptionCheckGen extends Object
A check generator that when given an exception, generates either an ExpectedExceptionCheck object or an EmptyExceptionCheck. Resulting tests only enforce expected matching exceptions.
See Also:
  • Field Details

    • accessibility

      private AccessibilityPredicate accessibility
      A predicate to determine accessibility of exception classes.
  • Constructor Details

    • ExpectedExceptionCheckGen

      public ExpectedExceptionCheckGen(AccessibilityPredicate accessibility)
      Create an object that generates expected exception checks for exceptions that satisfy the given predicate, and empty exception checks for others.
      Parameters:
      accessibility - a predicate to determine accessibility of exception classes
  • Method Details

    • getExceptionCheck

      ExceptionCheck getExceptionCheck(ExceptionalExecution exec, ExecutableSequence eseq, int statementIndex)
      Constructs an ExceptionCheck for the given exception and statement based on criteria of this generator.
      Parameters:
      exec - the exception outcome of executing the statement in a sequence
      eseq - the sequence where exception occurred
      statementIndex - the position of the statement in the sequence
      Returns:
      an ExpectedExceptionCheck object for exception and statement if exception is checked, and an EmptyExceptionCheck otherwise
    • nearestAccessibleSuperclass

      private static Class<?> nearestAccessibleSuperclass(Class<?> c, AccessibilityPredicate accessibility)
      Returns the nearest accessible superclass -- usually the argument itself.
      Parameters:
      c - the class for which superclass is needed
      accessibility - only superclasess satisfying this predicate may be returned
      Returns:
      the nearest public class that is the argument or a superclass
    • getCatchClassName

      public static String getCatchClassName(Class<? extends Throwable> c, AccessibilityPredicate accessibility)
      Returns the canonical name for the nearest accessible class that will catch an exception with the given class.
      Parameters:
      c - the exception class
      accessibility - only superclasess satisfying this predicate may be returned
      Returns:
      the nearest public accessible, c or a superclass of c
    • getCatchClassName

      public static String getCatchClassName(Class<? extends Throwable> c)
      Returns the canonical name for the nearest public class that will catch an exception with the given class.
      Parameters:
      c - the exception class
      Returns:
      the nearest public accessible, c or a superclass of c