public class DefaultTestCase extends Object implements TestCase, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected static AtomicInteger |
idGenerator |
protected ListenableList<Statement> |
statements
The statements
|
| Constructor and Description |
|---|
DefaultTestCase()
Constructor
|
| 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
|
void |
addListener(Listener<Void> listener)
Add a listener.
|
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 |
changeClassLoader(ClassLoader loader)
changeClassLoader
|
void |
chop(int length)
Remove all statements after a given position
|
void |
clearCoveredGoals()
Remove all covered goals
|
DefaultTestCase |
clone()
clone
|
boolean |
contains(Statement statement) |
void |
deleteListener(Listener<Void> listener)
Remove the given Listener such that he will no longer receive event
updates.
|
boolean |
equals(Object obj) |
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
|
ClassLoader |
getChangedClassLoader() |
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
|
int |
hashCode()
Equality check
|
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)
|
Iterator<Statement> |
iterator() |
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 |
removeDownCasts() |
void |
replace(VariableReference var1,
VariableReference var2)
Replace a VariableReference with another one
|
void |
setFailing() |
void |
setFailing(boolean failing) |
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
|
String |
toString() |
finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected static final AtomicInteger idGenerator
protected final ListenableList<Statement> statements
public int getID()
TestCasepublic void accept(TestVisitor visitor)
accept in interface TestCasevisitor - a TestVisitor object.public void addAssertions(TestCase other)
addAssertions in interface TestCaseother - The other test casepublic void addContractViolation(ContractViolation violation)
TestCaseaddContractViolation in interface TestCaseviolation - a ContractViolation object.public Set<ContractViolation> getContractViolations()
TestCasegetContractViolations in interface TestCasepublic void addCoveredGoal(TestFitnessFunction goal)
addCoveredGoal in interface TestCasegoal - a TestFitnessFunction object.public boolean isGoalCovered(TestFitnessFunction goal)
TestCaseisGoalCovered in interface TestCasepublic void addListener(Listener<Void> listener)
Listener#fireEvent(Object) method.addListener in interface Listenable<Void>listener - The listener to add.public VariableReference addStatement(Statement statement)
addStatement in interface TestCasestatement - New statementpublic VariableReference addStatement(Statement statement, int position)
addStatement in interface TestCasestatement - New statementposition - Position at which to addpublic void addStatements(List<? extends Statement> statements)
addStatements
addStatements in interface TestCasestatements - a List object.public void changeClassLoader(ClassLoader loader)
changeClassLoader
loader - a ClassLoader object.public ClassLoader getChangedClassLoader()
public void chop(int length)
public int sliceFor(VariableReference var)
public void clearCoveredGoals()
clearCoveredGoals in interface TestCasepublic DefaultTestCase clone()
clone
Create a copy of the test casepublic void deleteListener(Listener<Void> listener)
deleteListener in interface Listenable<Void>listener - The listener to remove.public Set<Class<?>> getAccessedClasses()
getAccessedClasses in interface TestCasepublic List<Assertion> getAssertions()
getAssertions in interface TestCasepublic Set<TestFitnessFunction> getCoveredGoals()
getCoveredGoals in interface TestCaseSet object.public Set<Class<?>> getDeclaredExceptions()
getDeclaredExceptions
getDeclaredExceptions in interface TestCaseSet object.public AccessedEnvironment getAccessedEnvironment()
TestCasegetAccessedEnvironment in interface TestCaseList object.public Set<VariableReference> getDependencies(VariableReference var)
getDependencies in interface TestCasevar - Variable to check forpublic VariableReference getLastObject(Type type) throws ConstructionFailedException
TestCasegetLastObject in interface TestCaseConstructionFailedExceptionpublic VariableReference getLastObject(Type type, int position) throws ConstructionFailedException
TestCasegetLastObject in interface TestCaseConstructionFailedExceptionpublic Object getObject(VariableReference reference, Scope scope)
public List<VariableReference> getObjects(int position)
getObjects in interface TestCaseposition - a int.List object.public List<VariableReference> getObjects(Type type, int position)
getObjects in interface TestCasetype - a Type object.position - a int.List object.public VariableReference getRandomNonNullNonPrimitiveObject(Type type, int position) throws ConstructionFailedException
getRandomNonNullNonPrimitiveObject in interface TestCasetype - a Type object.position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existspublic VariableReference getRandomNonNullObject(Type type, int position) throws ConstructionFailedException
getRandomNonNullObject in interface TestCasetype - a Type object.position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existspublic VariableReference getRandomObject()
getRandomObject in interface TestCasepublic VariableReference getRandomObject(int position)
getRandomObject in interface TestCaseposition - Upper bound in test case up to which objects are consideredVariableReference object.public VariableReference getRandomObject(Type type) throws ConstructionFailedException
getRandomObject in interface TestCasetype - Class we are looking forConstructionFailedException - if any.public VariableReference getRandomObject(Type type, int position) throws ConstructionFailedException
getRandomObject in interface TestCasetype - a Type object.position - Upper bound in test case up to which objects are consideredVariableReference object.ConstructionFailedException - if no such object existspublic Set<VariableReference> getReferences(VariableReference var)
getReferences in interface TestCasevar - Variable to check forpublic VariableReference getReturnValue(int position)
getReturnValue in interface TestCaseposition - a int.VariableReference object.public Statement getStatement(int position)
getStatement in interface TestCaseposition - Index of statementpublic boolean hasStatement(int position)
hasStatement in interface TestCaseposition - Index of statementpublic boolean hasAssertions()
hasAssertions in interface TestCasepublic boolean hasCastableObject(Type type)
hasCastableObject
hasCastableObject in interface TestCasetype - a Type object.public boolean hasObject(Type type, int position)
public boolean hasReferences(VariableReference var)
hasReferences in interface TestCasevar - Variable to check forpublic boolean isAccessible()
TestCaseisAccessible in interface TestCasepublic boolean isEmpty()
isEmpty
public void setFailing()
setFailing in interface TestCasepublic 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.
public boolean isUnstable()
TestCaseisUnstable in interface TestCasepublic boolean isValid()
public void remove(int position)
public void removeAssertion(Assertion assertion)
TestCaseremoveAssertion in interface TestCasepublic void removeAssertions()
removeAssertions in interface TestCasepublic void removeDownCasts()
public void replace(VariableReference var1, VariableReference var2)
public void setFailing(boolean failing)
public VariableReference setStatement(Statement statement, int position)
setStatement in interface TestCasestatement - New statementposition - Position at which to addpublic void setUnstable(boolean unstable)
TestCasesetUnstable in interface TestCasepublic int sizeWithAssertions()
sizeWithAssertions in interface TestCasepublic String toCode()
public String toCode(Map<Integer,Throwable> exceptions)
Copyright © 2010–2017 EvoSuite. All rights reserved.