public class TestFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
VariableReference |
addConstructor(TestCase test,
GenericConstructor constructor,
int position,
int recursionDepth) |
VariableReference |
addConstructor(TestCase test,
GenericConstructor constructor,
Type exactType,
int position,
int recursionDepth)
Add constructor at given position if max recursion depth has not been
reached
|
VariableReference |
addField(TestCase test,
GenericField field,
int position,
int recursionDepth)
Add a field to the test case
|
VariableReference |
addFieldAssignment(TestCase test,
GenericField field,
int position,
int recursionDepth)
Add method at given position if max recursion depth has not been reached
|
VariableReference |
addFieldFor(TestCase test,
VariableReference callee,
GenericField field,
int position)
Add reference to a field of variable "callee"
|
VariableReference |
addFunctionalMock(TestCase test,
Type type,
int position,
int recursionDepth) |
VariableReference |
addMethod(TestCase test,
GenericMethod method,
int position,
int recursionDepth)
Add method at given position if max recursion depth has not been reached
|
VariableReference |
addMethodFor(TestCase test,
VariableReference callee,
GenericMethod method,
int position)
Add a call on the method for the given callee at position
|
void |
appendStatement(TestCase test,
Statement statement)
Append statement s, trying to satisfy parameters
Called from TestChromosome when doing crossover
|
void |
assignArray(TestCase test,
VariableReference array,
int arrayIndex,
int position)
Assign a value to an array index
|
protected void |
assignArray(TestCase test,
VariableReference array,
int arrayIndex,
int position,
List<VariableReference> objects)
Assign a value to an array index for a given set of objects
|
VariableReference |
attemptGeneration(TestCase test,
Type type,
int position)
Attempt to generate a non-null object; initialize recursion level to 0
|
protected VariableReference |
attemptGeneration(TestCase test,
Type type,
int position,
int recursionDepth,
boolean allowNull,
VariableReference generatorRefToExclude,
boolean canUseMocks,
boolean canReuseExistingVariables)
Try to generate an object of a given type
|
protected VariableReference |
attemptObjectGeneration(TestCase test,
int position,
int recursionDepth,
boolean allowNull)
Try to generate an object suitable for Object.class
|
void |
changeCall(TestCase test,
Statement statement,
GenericAccessibleObject<?> call)
Replace the statement with a new statement using given call
|
boolean |
changeRandomCall(TestCase test,
Statement statement) |
VariableReference |
createObject(TestCase test,
Type type,
int position,
int recursionDepth,
VariableReference generatorRefToExclude) |
VariableReference |
createObject(TestCase test,
Type type,
int position,
int recursionDepth,
VariableReference generatorRefToExclude,
boolean allowNull,
boolean canUseFunctionalMocks,
boolean canReuseVariables)
Create a new non-null, non-primitive object and return reference
|
boolean |
deleteStatement(TestCase test,
int position)
Delete the statement at position from the test case and remove all
references to it
|
boolean |
deleteStatementGracefully(TestCase test,
int position) |
static TestFactory |
getInstance() |
boolean |
insertRandomCall(TestCase test,
int position)
Insert a random call for the UUT at the given position
|
int |
insertRandomCallOnEnvironment(TestCase test,
int lastValidPosition) |
boolean |
insertRandomCallOnObjectAt(TestCase test,
VariableReference var,
int position) |
int |
insertRandomStatement(TestCase test,
int lastPosition) |
void |
reset()
We keep track of calls already attempted to avoid infinite recursion
|
List<VariableReference> |
satisfyParameters(TestCase test,
VariableReference callee,
List<Type> parameterTypes,
int position,
int recursionDepth,
boolean allowNull,
boolean excludeCalleeGenerators,
boolean canReuseExistingVariables)
Satisfy a list of parameters by reusing or creating variables
|
public void reset()
public static TestFactory getInstance()
public VariableReference addFunctionalMock(TestCase test, Type type, int position, int recursionDepth) throws ConstructionFailedException, IllegalArgumentException
public VariableReference addConstructor(TestCase test, GenericConstructor constructor, int position, int recursionDepth) throws ConstructionFailedException
ConstructionFailedExceptionpublic VariableReference addConstructor(TestCase test, GenericConstructor constructor, Type exactType, int position, int recursionDepth) throws ConstructionFailedException
constructor - position - recursionDepth - ConstructionFailedExceptionpublic VariableReference addField(TestCase test, GenericField field, int position, int recursionDepth) throws ConstructionFailedException
test - field - position - ConstructionFailedExceptionpublic VariableReference addFieldAssignment(TestCase test, GenericField field, int position, int recursionDepth) throws ConstructionFailedException
test - field - position - recursionDepth - ConstructionFailedExceptionpublic VariableReference addFieldFor(TestCase test, VariableReference callee, GenericField field, int position) throws ConstructionFailedException
test - callee - field - position - ConstructionFailedExceptionpublic VariableReference addMethod(TestCase test, GenericMethod method, int position, int recursionDepth) throws ConstructionFailedException
test - method - position - recursionDepth - ConstructionFailedExceptionpublic VariableReference addMethodFor(TestCase test, VariableReference callee, GenericMethod method, int position) throws ConstructionFailedException
test - callee - method - position - ConstructionFailedExceptionpublic void appendStatement(TestCase test, Statement statement) throws ConstructionFailedException
test - statement - ConstructionFailedExceptionpublic void assignArray(TestCase test, VariableReference array, int arrayIndex, int position) throws ConstructionFailedException
test - array - arrayIndex - position - ConstructionFailedExceptionprotected void assignArray(TestCase test, VariableReference array, int arrayIndex, int position, List<VariableReference> objects) throws ConstructionFailedException
test - array - arrayIndex - position - objects - ConstructionFailedExceptionpublic VariableReference attemptGeneration(TestCase test, Type type, int position) throws ConstructionFailedException
ConstructionFailedExceptionprotected VariableReference attemptGeneration(TestCase test, Type type, int position, int recursionDepth, boolean allowNull, VariableReference generatorRefToExclude, boolean canUseMocks, boolean canReuseExistingVariables) throws ConstructionFailedException
test - type - position - recursionDepth - allowNull - ConstructionFailedExceptionprotected VariableReference attemptObjectGeneration(TestCase test, int position, int recursionDepth, boolean allowNull) throws ConstructionFailedException
test - position - recursionDepth - allowNull - ConstructionFailedExceptionpublic void changeCall(TestCase test, Statement statement, GenericAccessibleObject<?> call) throws ConstructionFailedException
test - statement - call - ConstructionFailedExceptionpublic VariableReference createObject(TestCase test, Type type, int position, int recursionDepth, VariableReference generatorRefToExclude) throws ConstructionFailedException
ConstructionFailedExceptionpublic VariableReference createObject(TestCase test, Type type, int position, int recursionDepth, VariableReference generatorRefToExclude, boolean allowNull, boolean canUseFunctionalMocks, boolean canReuseVariables) throws ConstructionFailedException
test - type - position - recursionDepth - ConstructionFailedExceptionpublic boolean deleteStatement(TestCase test, int position) throws ConstructionFailedException
test - position - ConstructionFailedExceptionpublic boolean deleteStatementGracefully(TestCase test, int position) throws ConstructionFailedException
test - position - ConstructionFailedExceptionpublic int insertRandomCallOnEnvironment(TestCase test, int lastValidPosition)
test - lastValidPosition - public boolean insertRandomCall(TestCase test, int position)
test - position - public boolean insertRandomCallOnObjectAt(TestCase test, VariableReference var, int position)
public int insertRandomStatement(TestCase test, int lastPosition)
public List<VariableReference> satisfyParameters(TestCase test, VariableReference callee, List<Type> parameterTypes, int position, int recursionDepth, boolean allowNull, boolean excludeCalleeGenerators, boolean canReuseExistingVariables) throws ConstructionFailedException
test - parameterTypes - position - recursionDepth - ConstructionFailedExceptionCopyright © 2010–2017 EvoSuite. All rights reserved.