public abstract class AbstractStatement extends Object implements Statement, Serializable
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractStatement.Executer
An interface to enable the concrete statements to use the executer/1
method.
|
| Modifier and Type | Field and Description |
|---|---|
protected Set<Assertion> |
assertions |
protected String |
comment |
protected static org.slf4j.Logger |
logger
Constant
logger |
protected VariableReference |
retval
The return value of this statement.
|
protected TestCase |
tc
Reference of the test case this statement belongs to.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractStatement(TestCase tc,
Type type)
Constructor for AbstractStatement.
|
protected |
AbstractStatement(TestCase tc,
VariableReference retval)
Constructor for AbstractStatement.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAssertion(Assertion assertion)
Add a new assertion to statement
|
void |
addComment(String comment)
A statement can have a textual comment that will be included
in the JUnit output
|
void |
changeClassLoader(ClassLoader loader)
Class instances are bound to a class loader - if we want to reexecute a
test on a different classloader we need to be able to change the class of
the reflection object
|
Statement |
clone()
Create deep copy of statement
|
Statement |
clone(TestCase newTestCase)
clone
|
Set<Assertion> |
copyAssertions(TestCase newTestCase,
int offset)
copyAssertions
|
protected Throwable |
exceptionHandler(AbstractStatement.Executer code)
This method abstracts the exception handling away from the concrete
statements.
|
String |
getAssertionCode()
Get Java code representation of assertions
|
protected Set<VariableReference> |
getAssertionReferences()
getAssertionReferences
|
Set<Assertion> |
getAssertions()
Return list of assertions
|
String |
getCode()
Create a string representing the statement as Java code
|
String |
getCode(Throwable exception)
Create a string representing the statement as Java code
|
String |
getComment()
Retrieve comment for this statement
|
Set<Class<?>> |
getDeclaredExceptions()
getDeclaredExceptions
|
static Class<?> |
getExceptionClass(Throwable t)
getExceptionClass
|
int |
getNumParameters()
Retrieve the number of parameters of this statement
|
int |
getPosition()
getPosition
|
Class<?> |
getReturnClass()
getReturnClass
|
Type |
getReturnType()
getReturnType
|
VariableReference |
getReturnValue()
getReturnValue
|
TestCase |
getTestCase()
Retrieve the test case this statement is part of
|
boolean |
hasAssertions()
Check if there are assertions
|
boolean |
isAccessible()
Determine if the underlying reflection object is currently accessible
|
boolean |
isDeclaredException(Throwable t)
Tests if the throwable defined by t is declared to be thrown by the
underlying type.
|
boolean |
isReflectionStatement() |
boolean |
isValid()
Various consistency checks.
|
boolean |
mutate(TestCase test,
TestFactory factory)
mutate
|
void |
negate()
negate
|
boolean |
references(VariableReference var)
Check if the statement makes use of var
|
void |
removeAssertion(Assertion assertion)
Delete assertion attached to this statement
|
void |
removeAssertions()
Delete all assertions attached to this statement
|
void |
setAssertions(Set<Assertion> assertions)
Sets the set of assertions to statement
|
void |
setRetval(VariableReference newRetVal)
setRetval
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcopy, equals, execute, getAccessibleObject, getUniqueVariableReferences, getVariableReferences, hashCode, isAssignmentStatement, replace, sameprotected static final org.slf4j.Logger logger
loggerprotected VariableReference retval
protected final TestCase tc
protected String comment
protected AbstractStatement(TestCase tc, VariableReference retval) throws IllegalArgumentException
Constructor for AbstractStatement.
tc - a TestCase object.retval - a VariableReference object.IllegalArgumentExceptionprotected AbstractStatement(TestCase tc, Type type) throws IllegalArgumentException
Constructor for AbstractStatement.
tc - a TestCase object.type - a Type object.IllegalArgumentExceptionprotected Throwable exceptionHandler(AbstractStatement.Executer code) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException, InstantiationException
code - a AbstractStatement.Executer
object.Throwable object.InvocationTargetException - if any.IllegalArgumentException - if any.IllegalAccessException - if any.InstantiationException - if any.public boolean references(VariableReference var)
references in interface Statementvar - Variable we are checking forprotected Set<VariableReference> getAssertionReferences()
getAssertionReferences
Set object.public void setRetval(VariableReference newRetVal) throws IllegalArgumentException
setRetval
setRetval in interface StatementnewRetVal - a VariableReference object.IllegalArgumentExceptionpublic String getCode()
public String getCode(Throwable exception)
public void addComment(String comment)
StatementaddComment in interface Statementpublic String getComment()
StatementgetComment in interface Statementpublic final Statement clone()
public Type getReturnType()
getReturnType
getReturnType in interface Statementpublic Class<?> getReturnClass()
getReturnClass
getReturnClass in interface Statementpublic VariableReference getReturnValue()
getReturnValue
getReturnValue in interface Statementpublic int getNumParameters()
StatementgetNumParameters in interface Statementpublic TestCase getTestCase()
StatementgetTestCase in interface Statementpublic Set<Assertion> copyAssertions(TestCase newTestCase, int offset)
copyAssertions
Create copies of all attached assertionscopyAssertions in interface StatementnewTestCase - the testcase in which this statement will be insertedoffset - a int.Set object.public boolean hasAssertions()
hasAssertions in interface Statementpublic void addAssertion(Assertion assertion)
addAssertion in interface Statementassertion - Assertion to be addedpublic void setAssertions(Set<Assertion> assertions)
setAssertions in interface Statementassertions - a Set object.public String getAssertionCode()
getAssertionCode in interface Statementpublic void removeAssertions()
removeAssertions in interface Statementpublic void removeAssertion(Assertion assertion)
removeAssertion in interface Statementassertion - a Assertion object.public Set<Assertion> getAssertions()
getAssertions in interface StatementSet object.public Set<Class<?>> getDeclaredExceptions()
getDeclaredExceptions
getDeclaredExceptions in interface StatementSet object.public int getPosition()
getPosition
getPosition in interface Statementpublic boolean isAccessible()
StatementisAccessible in interface Statementpublic boolean isValid()
public boolean isDeclaredException(Throwable t)
isDeclaredException in interface Statementt - a Throwable object.public boolean mutate(TestCase test, TestFactory factory)
mutate
mutate in interface Statementtest - a TestCase object.factory - a TestFactory object.public void changeClassLoader(ClassLoader loader)
changeClassLoader in interface Statementloader - a ClassLoader object.public void negate()
negate
public boolean isReflectionStatement()
isReflectionStatement in interface StatementCopyright © 2010–2017 EvoSuite. All rights reserved.