Package randoop.test
Class ExpectedExceptionGenerator
java.lang.Object
randoop.test.TestCheckGenerator
randoop.test.ExpectedExceptionGenerator
A
TestCheckGenerator
that generates checks for exceptions that are expected at the final
statement of a sequence. Creates a ExpectedExceptionCheck
that is returned in a RegressionChecks
collection if the exception occurs, or a ErrorRevealingChecks
collection if not.
Note that this generator is distinct from other check generators that either return regression checks or error-revealing checks.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List<List<ThrowsClause>>
The list of lists of throws clauses for which the guard expression was satisfied. -
Constructor Summary
ConstructorDescriptionExpectedExceptionGenerator
(List<List<ThrowsClause>> exceptionSets) Creates anExpectedExceptionGenerator
for the list of sets of expected exceptions. -
Method Summary
Modifier and TypeMethodDescriptionprivate static ClassOrInterfaceType
findMatchingExpectedType
(ClassOrInterfaceType throwableType, List<ThrowsClause> throwsClauses) Find the first ThrowsClause whose exception is a supertype of (or equal to)throwableType
, and return that exception type.TestChecks<?>
Generate aTestChecks
object for the executed sequenceeseq
based on the criteria of this generator.Returns the types of the expected exceptions.private ErrorRevealingChecks
getMissingExceptionTestChecks
(int finalIndex) Return an ErrorRevealingChecks that checks for a missing exception at the given index.Methods inherited from class randoop.test.TestCheckGenerator
hasGenerator
-
Field Details
-
exceptionSets
The list of lists of throws clauses for which the guard expression was satisfied. Each list of throwsclauses represents one specification, and each such list must be satisfied.
-
-
Constructor Details
-
ExpectedExceptionGenerator
Creates anExpectedExceptionGenerator
for the list of sets of expected exceptions.- Parameters:
exceptionSets
- a list of lists of expected exceptions to be searched when testing an exception thrown by the operation in the final statement of the sequence. Each list of expected exceptions must be satisfied.
-
-
Method Details
-
generateTestChecks
Generate aTestChecks
object for the executed sequenceeseq
based on the criteria of this generator.Adds checks for an expected exception at the final statement of the sequence.
- Specified by:
generateTestChecks
in classTestCheckGenerator
- Parameters:
eseq
- the sequence for which checks are generated- Returns:
- the generated check set for the sequence
-
findMatchingExpectedType
private static ClassOrInterfaceType findMatchingExpectedType(ClassOrInterfaceType throwableType, List<ThrowsClause> throwsClauses) Find the first ThrowsClause whose exception is a supertype of (or equal to)throwableType
, and return that exception type.- Parameters:
throwableType
- the type to search forthrowsClauses
- theThrowsClause
s to search within- Returns:
- the type in the first matching
ThrowsClause
, or null if none match
-
getMissingExceptionTestChecks
Return an ErrorRevealingChecks that checks for a missing exception at the given index.- Parameters:
finalIndex
- the index- Returns:
- the ErrorRevealingChecks object
-
getExpected
Returns the types of the expected exceptions. Each list of throwsclauses represents one specification, and each such list must be satisfied.- Returns:
- the types of the expected exceptions
-