|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jwalk.core.TestCase
public abstract class TestCase
TestCase represents a single invocation, construction or constant selection.
A TestCase is a single element of a TestSequence, and represents one of
a Method invocation, a Constructor invocation, or an Enum value selection.
The descendants of TestCase handle these three different kinds of case:
InvokeTestCase, CreateTestCase, EnumTestCase. All of these return the
created (or selected) value, when they are executed.
A TestCase also stores an encoded representation of the state of the test
object, which is computed when the TestCase is executed. This allows
JWalkers to determine if a sequence of invocations caused the test object
to change state, or visit a previously-visited state.
Field Summary | |
---|---|
protected static StateInspector |
inspector
The StateInspector to use, when inspecting object states. |
protected int |
state
The encoded state of the target object. |
Constructor Summary | |
---|---|
protected |
TestCase()
Initialises the abstract part of a TestCase. |
Method Summary | |
---|---|
TestCase |
clone()
Clones a shallow copy of this TestCase. |
abstract java.lang.Object |
execute(ObjectGenerator generator,
java.lang.Object target)
Executes this TestCase, returning the result. |
abstract java.lang.String |
getKey(ObjectGenerator generator)
Returns a unique indexing key for this TestCase. |
abstract java.lang.reflect.Member |
getOperation()
Returns the tested operation for this TestCase. |
abstract java.lang.Class<?> |
getReturnType()
Returns the result type of the tested operation. |
int |
getState()
Returns the encoded state of the target object. |
static void |
setInspector(StateInspector inspector)
Sets the StateInspector to use for all TestCases. |
abstract java.lang.String |
toString(ObjectGenerator generator)
Returns a pretty-printed representation of this TestCase. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static StateInspector inspector
protected int state
Constructor Detail |
---|
protected TestCase()
Method Detail |
---|
public static void setInspector(StateInspector inspector)
inspector
- the StateInspector to use.public TestCase clone()
clone
in class java.lang.Object
public int getState()
public abstract java.lang.reflect.Member getOperation()
getName()
.
public abstract java.lang.Class<?> getReturnType()
public abstract java.lang.Object execute(ObjectGenerator generator, java.lang.Object target) throws java.lang.reflect.InvocationTargetException, GeneratorException, ExecutionException
generator
- the ObjectGenerator for synthesising test inputs.target
- the target object, initially null.
java.lang.reflect.InvocationTargetException
- if the tested operation raises
an exception internally. This is later handled by TestSequence, which
reports the exception as the result of the test.
GeneratorException
- if any constructor or method argument value
could not be synthesised. A CustomGenerator must be provided that is
capable of synthesising values of the argument type.
ExecutionException
- if any constructor or method could not be
invoked, or if it exhibited unpredictable random behaviour.public abstract java.lang.String toString(ObjectGenerator generator)
generator
- the ObjectGenerator which synthesised the parameters.
public abstract java.lang.String getKey(ObjectGenerator generator)
generator
- the ObjectGenerator which synthesised the parameters.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |