Package randoop.test
Class ExpectedExceptionCheckGen
java.lang.Object
randoop.test.ExpectedExceptionCheckGen
A check generator that when given an exception, generates either an
ExpectedExceptionCheck
object or an EmptyExceptionCheck
. Resulting tests only enforce
expected matching exceptions.-
Field Summary
Modifier and TypeFieldDescriptionprivate AccessibilityPredicate
A predicate to determine accessibility of exception classes. -
Constructor Summary
ConstructorDescriptionExpectedExceptionCheckGen
(AccessibilityPredicate accessibility) Create an object that generates expected exception checks for exceptions that satisfy the given predicate, and empty exception checks for others. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getCatchClassName
(Class<? extends Throwable> c) Returns the canonical name for the nearest public class that will catch an exception with the given class.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.(package private) ExceptionCheck
getExceptionCheck
(ExceptionalExecution exec, ExecutableSequence eseq, int statementIndex) Constructs anExceptionCheck
for the given exception and statement based on criteria of this generator.private static Class<?>
nearestAccessibleSuperclass
(Class<?> c, AccessibilityPredicate accessibility) Returns the nearest accessible superclass -- usually the argument itself.
-
Field Details
-
accessibility
A predicate to determine accessibility of exception classes.
-
-
Constructor Details
-
ExpectedExceptionCheckGen
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 anExceptionCheck
for the given exception and statement based on criteria of this generator.- Parameters:
exec
- the exception outcome of executing the statement in a sequenceeseq
- the sequence where exception occurredstatementIndex
- the position of the statement in the sequence- Returns:
- an
ExpectedExceptionCheck
object for exception and statement if exception is checked, and anEmptyExceptionCheck
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 neededaccessibility
- 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 classaccessibility
- only superclasess satisfying this predicate may be returned- Returns:
- the nearest public accessible, c or a superclass of c
-
getCatchClassName
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
-