public interface TestCase extends Iterable<Statement>, Cloneable, Listenable<Void>
| Modifier and Type | Method and Description |
|---|---|
void |
accept(TestVisitor visitor)
Handle test visitor
|
void |
addAssertions(TestCase other)
Copy all the assertions from other test case
|
void |
addContractViolation(ContractViolation violation)
Keep track of an additional test failure
|
void |
addCoveredGoal(TestFitnessFunction goal)
Keep track of an additional covered goal
|
VariableReference |
addStatement(Statement statement)
Append new statement at end of test case
|
VariableReference |
addStatement(Statement statement,
int position)
Add new statement at position and fix following variable references
|
void |
addStatements(List<? extends Statement> statements)
addStatements
|
void |
chop(int length)
Remove all statements after a given position
|
void |
clearCoveredGoals()
Remove all covered goals
|
TestCase |
clone()
clone
|
boolean |
contains(Statement statement) |
Set<Class<?>> |
getAccessedClasses()
Determine the set of classes that are accessed by the test case
|
AccessedEnvironment |
getAccessedEnvironment()
Retrieve an object containing information about what environment components this test interacted with
|
List<Assertion> |
getAssertions()
Get all assertions that exist for this test case
|
Set<ContractViolation> |
getContractViolations()
Retrieve all violations observed during test execution
|
Set<TestFitnessFunction> |
getCoveredGoals()
Retrieve all coverage goals covered by this test
|
Set<Class<?>> |
getDeclaredExceptions()
getDeclaredExceptions
|
Set<VariableReference> |
getDependencies(VariableReference var)
Determine the set of variables that var depends on
|
int |
getID()
Get an unique id representing this test.
|
VariableReference |
getLastObject(Type type)
Get the last object of the defined type
|
VariableReference |
getLastObject(Type type,
int position)
Get the last object of the defined type
|
Object |
getObject(VariableReference reference,
Scope scope)
Get actual object represented by a variable for a given execution scope
|
List<VariableReference> |
getObjects(int position)
Get all objects up to position satisfying constraint
|
List<VariableReference> |
getObjects(Type type,
int position)
Get all objects up to position satisfying constraint
|
VariableReference |
getRandomNonNullNonPrimitiveObject(Type type,
int position)
Get a random object matching type
|
VariableReference |
getRandomNonNullObject(Type type,
int position)
Get a random object matching type
|
VariableReference |
getRandomObject()
Get a random object matching type
|
VariableReference |
getRandomObject(int position)
Get a random object matching type
|
VariableReference |
getRandomObject(Type type)
Get a random object matching type
|
VariableReference |
getRandomObject(Type type,
int position)
Get a random object matching type
|
Set<VariableReference> |
getReferences(VariableReference var)
Determine the set of variables that depend on var
|
VariableReference |
getReturnValue(int position)
Get return value (variable) of statement at position
|
Statement |
getStatement(int position)
Access statement by index
|
boolean |
hasAssertions()
Check if there are any assertions
|
boolean |
hasCastableObject(Type type)
hasCastableObject
|
boolean |
hasObject(Type type,
int position)
Check if the test case has an object of a given class
|
boolean |
hasReferences(VariableReference var)
Check if var is referenced after its definition
|
boolean |
hasStatement(int position)
Check if there is a statement at the given position.
|
boolean |
isAccessible()
Check if all methods/fields accessed are accessible also for the current SUT
|
boolean |
isEmpty()
isEmpty
|
boolean |
isFailing() |
boolean |
isGoalCovered(TestFitnessFunction goal)
Check if the current test case does cover the given goal.
|
boolean |
isPrefix(TestCase t)
Check if this test case is a prefix of t
|
boolean |
isUnstable()
A test can be unstable if its assertions fail, eg due to non-determinism,
non-properly handled static variables and side effects on environment, etc
|
boolean |
isValid()
Check if test case is valid (executable)
|
void |
remove(int position)
Remove statement at position and fix variable references
|
void |
removeAssertion(Assertion assertion)
Remove assertion from test case
|
void |
removeAssertions()
Remove all assertions from test case
|
void |
replace(VariableReference var1,
VariableReference var2)
Replace a VariableReference with another one
|
void |
setFailing() |
VariableReference |
setStatement(Statement statement,
int position)
Set new statement at position
|
void |
setUnstable(boolean unstable)
Define whether this test case is unstable or not
|
int |
size()
size
|
int |
sizeWithAssertions()
Get number of statements plus the number of assertions
|
int |
sliceFor(VariableReference var) |
String |
toCode()
Get Java code representation of the test case
|
String |
toCode(Map<Integer,Throwable> exceptions)
Get Java code representation of the test case
|
forEach, iterator, spliteratoraddListener, deleteListenerint getID()
void accept(TestVisitor visitor)
visitor - a TestVisitor object.void addAssertions(TestCase other)
other - The other test casevoid addCoveredGoal(TestFitnessFunction goal)
goal - a TestFitnessFunction object.void addContractViolation(ContractViolation violation)
violation - a ContractViolation object.VariableReference addStatement(Statement statement)
statement - New statementVariableReference addStatement(Statement statement, int position)
statement - New statementposition - Position at which to addvoid addStatements(List<? extends Statement> statements)
addStatements
statements - a List object.void chop(int length)
length - Length of the test case after choppingint sliceFor(VariableReference var)
void clearCoveredGoals()
boolean contains(Statement statement)
Set<Class<?>> getAccessedClasses()
AccessedEnvironment getAccessedEnvironment()
List object.List<Assertion> getAssertions()
Set<ContractViolation> getContractViolations()
Set<TestFitnessFunction> getCoveredGoals()
Set object.Set<Class<?>> getDeclaredExceptions()
getDeclaredExceptions
Set object.Set<VariableReference> getDependencies(VariableReference var)
var - Variable to check forVariableReference getLastObject(Type type) throws ConstructionFailedException
type - ConstructionFailedExceptionVariableReference getLastObject(Type type, int position) throws ConstructionFailedException
type - ConstructionFailedExceptionObject getObject(VariableReference reference, Scope scope)
reference - Variablescope - Excution scopeList<VariableReference> getObjects(int position)
position - a int.List object.List<VariableReference> getObjects(Type type, int position)
VariableReference getRandomNonNullNonPrimitiveObject(Type type, int position) throws ConstructionFailedException
type - a Type object.position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existsVariableReference getRandomNonNullObject(Type type, int position) throws ConstructionFailedException
type - a Type object.position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existsVariableReference getRandomObject()
ConstructionFailedException - if any.VariableReference getRandomObject(int position)
position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existsVariableReference getRandomObject(Type type) throws ConstructionFailedException
type - Class we are looking forConstructionFailedException - if any.VariableReference getRandomObject(Type type, int position) throws ConstructionFailedException
type - a Type object.position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existsSet<VariableReference> getReferences(VariableReference var)
var - Variable to check forVariableReference getReturnValue(int position)
position - a int.VariableReference object.Statement getStatement(int position)
position - Index of statementboolean hasStatement(int position)
position - Index of statementboolean hasAssertions()
boolean hasCastableObject(Type type)
hasCastableObject
type - a Type object.boolean hasObject(Type type, int position)
type - Type to look forposition - Upper bound up to which the test is checkedboolean hasReferences(VariableReference var)
var - Variable to check forboolean isAccessible()
boolean isEmpty()
isEmpty
boolean isFailing()
void setFailing()
boolean isGoalCovered(TestFitnessFunction goal)
goal - boolean isPrefix(TestCase t)
A test case A is a prefix of a test case B if
and only if the first length(A) statements of B are
equal to ones of A, in the same order.
In other words, B can be seen as an extension of A.
t - Test case to check againstboolean isUnstable()
boolean isValid()
void remove(int position)
position - a int.void removeAssertion(Assertion assertion)
void removeAssertions()
void replace(VariableReference var1, VariableReference var2)
var1 - The old variablevar2 - The new variableVariableReference setStatement(Statement statement, int position)
statement - New statementposition - Position at which to addvoid setUnstable(boolean unstable)
unstable - int size()
size
int sizeWithAssertions()
String toCode()
Copyright © 2010–2017 EvoSuite. All rights reserved.