Package randoop.test
Class RegressionCaptureGenerator
java.lang.Object
randoop.test.TestCheckGenerator
randoop.test.RegressionCaptureGenerator
A
TestCheckGenerator
that records regression checks on the values created by the
sequence.
NOTES:
- Only creates checks over values whose type is primitive or String.
- Does not create checks for Strings that contain the string ";@" as this is a good indication that at least part of the String came from a call of Object.toString() (e.g. "[[Ljava.lang.Object;@5780d9]" is the string representation of a list containing one Object).
-
Field Summary
Modifier and TypeFieldDescriptionprivate ExpectedExceptionCheckGen
The generator for expected exceptions.private boolean
Whether to include regression assertions.private final AccessibilityPredicate
The accessibility predicate.private OmitMethodsPredicate
The user-supplied predicate for methods that should not be called.private MultiMap<Type,
TypedClassOperation> The map from a type to the set of side-effect-free operations for the type. -
Constructor Summary
ConstructorDescriptionRegressionCaptureGenerator
(ExpectedExceptionCheckGen exceptionExpectation, MultiMap<Type, TypedClassOperation> sideEffectFreeMethodsByType, AccessibilityPredicate isAccessible, OmitMethodsPredicate omitMethodsPredicate, boolean includeAssertions) Create a RegressionCaptureGenerator. -
Method Summary
Modifier and TypeMethodDescriptionGenerate aTestChecks
object for the executed sequenceeseq
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
Return true if the method is Object.toString (which is nondeterministic for classes that have not overridden it).Methods inherited from class randoop.test.TestCheckGenerator
hasGenerator
-
Field Details
-
exceptionExpectation
The generator for expected exceptions. -
sideEffectFreeMethodsByType
The map from a type to the set of side-effect-free operations for the type. -
isAccessible
The accessibility predicate. -
omitMethodsPredicate
The user-supplied predicate for methods that should not be called. -
includeAssertions
private boolean includeAssertionsWhether to include regression assertions. If false, no assertions are added for sequences whose execution is NormalExecution.
-
-
Constructor Details
-
RegressionCaptureGenerator
public RegressionCaptureGenerator(ExpectedExceptionCheckGen exceptionExpectation, MultiMap<Type, TypedClassOperation> sideEffectFreeMethodsByType, AccessibilityPredicate isAccessible, OmitMethodsPredicate omitMethodsPredicate, boolean includeAssertions) Create a RegressionCaptureGenerator.- Parameters:
exceptionExpectation
- the generator for expected exceptionssideEffectFreeMethodsByType
- the map from a type to the side-effect-free operations for the typeisAccessible
- the accessibility predicateomitMethodsPredicate
- the user-supplied predicate for methods that should not be calledincludeAssertions
- whether to include regression assertions
-
-
Method Details
-
generateTestChecks
Generate aTestChecks
object for the executed sequenceeseq
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.- Specified by:
generateTestChecks
in classTestCheckGenerator
- Parameters:
eseq
- the sequence for which checks are generated- Returns:
- the generated check set for the sequence
- Throws:
Error
- if any statement is not executed, or exception occurs before last statement
-
isObjectToString
Return true if the method is Object.toString (which is nondeterministic for classes that have not overridden it).- Parameters:
m
- the method to test- Returns:
- true if the method is Object.toString
-
isAssertableMethod
public 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.- Parameters:
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 call- Returns:
- whether we can use this method or constructor in a side-effect-free assertion
- Throws:
IllegalArgumentException
- if m is not either a Method or a Constructor
-