public final class RegressionCaptureGenerator extends TestCheckGenerator
TestCheckGenerator
that records regression checks on the values created by the
sequence.
NOTES:
Modifier and Type | Field and Description |
---|---|
private ExpectedExceptionCheckGen |
exceptionExpectation
The generator for expected exceptions.
|
private boolean |
includeAssertions
Whether to include regression assertions.
|
private AccessibilityPredicate |
isAccessible
The accessibility predicate.
|
private static int |
MAX_ARRAY_LENGTH
The maximum length (inclusive) of arrays in generated tests.
|
private OmitMethodsPredicate |
omitMethodsPredicate
The user-supplied predicate for methods that should not be called.
|
private MultiMap<Type,TypedClassOperation> |
sideEffectFreeMethodsByType
The map from a type to the set of side-effect-free operations for the type.
|
Constructor and Description |
---|
RegressionCaptureGenerator(ExpectedExceptionCheckGen exceptionExpectation,
MultiMap<Type,TypedClassOperation> sideEffectFreeMethodsByType,
AccessibilityPredicate isAccessible,
OmitMethodsPredicate omitMethodsPredicate,
boolean includeAssertions)
Create a RegressionCaptureGenerator.
|
Modifier and Type | Method and Description |
---|---|
RegressionChecks |
generateTestChecks(ExecutableSequence eseq)
Generate a
TestChecks object for the executed sequence eseq based on the
criteria of this generator. |
static boolean |
isAssertableMethod(TypedClassOperation m,
OmitMethodsPredicate omitMethodsPredicate,
AccessibilityPredicate accessibility)
Returns true if the given side-effect-free method or constructor can be used in an assertion in
Randoop.
|
private static boolean |
isObjectToString(TypedClassOperation m)
Return true if the method is Object.toString (which is nondeterministic for classes that have
not overridden it).
|
hasGenerator
private ExpectedExceptionCheckGen exceptionExpectation
private MultiMap<Type,TypedClassOperation> sideEffectFreeMethodsByType
private final AccessibilityPredicate isAccessible
private OmitMethodsPredicate omitMethodsPredicate
private boolean includeAssertions
private static final int MAX_ARRAY_LENGTH
public RegressionCaptureGenerator(ExpectedExceptionCheckGen exceptionExpectation, MultiMap<Type,TypedClassOperation> sideEffectFreeMethodsByType, AccessibilityPredicate isAccessible, OmitMethodsPredicate omitMethodsPredicate, boolean includeAssertions)
exceptionExpectation
- the generator for expected exceptionssideEffectFreeMethodsByType
- the map from a type to the side-effect-free operations for
the type; assertions may call these methodsisAccessible
- the accessibility predicateomitMethodsPredicate
- the user-supplied predicate for methods that should not be calledincludeAssertions
- whether to include regression assertionspublic RegressionChecks generateTestChecks(ExecutableSequence eseq)
TestChecks
object for the executed sequence eseq
based on the
criteria of this generator.
Iterates over all statements of the sequence to create regression assertions. If visitor is
set to include assertions, then assertions are generated for both normal execution and
exceptions. A try-catch block is always generated for exceptions, but whether assertions are
included is determined by the ExpectedExceptionCheckGen
given when creating this
visitor.
generateTestChecks
in class TestCheckGenerator
eseq
- the sequence for which checks are generatedjava.lang.Error
- if any statement is not executed, or exception occurs before last statementprivate static boolean isObjectToString(TypedClassOperation m)
m
- the method to testpublic static boolean isAssertableMethod(TypedClassOperation m, OmitMethodsPredicate omitMethodsPredicate, AccessibilityPredicate accessibility)
m
- a method or constructor, which must be side-effect-freeomitMethodsPredicate
- the user-supplied predicate for methods and constructors that
should not be calledaccessibility
- the predicate used to check whether a method or constructor is accessible
to calljava.lang.IllegalArgumentException
- if m is not either a Method or a Constructor