| java.lang.Object U2.T2.Engine U2.T2.RndEngine
RndEngine | public class RndEngine extends Engine (Code) | | Implements test engine for random testing; it provides the T2's
main testing API.
An instance of this class is a test engine. When given a target
class to test, an engine randomly generates executions, and also
randomly generates objects needed as parameters for method called
during the executions. The executions are checked against the class
invariant of the target class and its other specifications if
present.
What is being checked?
An instance of this class is a test engine. An engine generates
executions, looking for violations. Executions leading to
violations are reported and can be saved for regression. These are
the kinds of violations checked by the engine:
- INTERNAL error. When a method of the target object raises an
Error, which is not an AssertionError, or RuntimeException.
- ASSERTION violation. When a method (or its specification)
raises an AssertionError, which is not marked by "PRE". If it is
marked by PRE then its pre-condition is not met, in which case the
execution will be discarded.
- CLASSINV violation. This happens when the state after a step
in an execution violates the class invariant.
Exception thrown by the class invariant will be considered as
false. If it throws an unchecked exception, the engine will give a
warning.
See Also: U2.T2.Engine |
Field Summary | |
protected BaseDomain | baseDomain The base domain used by the engine. | protected float | chooseFieldUpdateProb The probability to do field update rather than method call. | protected LinkedList<Trace> | collectedTraces Collected execution traces. | protected float | generateNullProb When trying to generate an instance of C, and one cannot be
found in the base domain, and the engine decided not to look in
the pool (hence generating a fresh one), this is the
probability of generating null. | protected InterfaceMap | interfaceMap An interface map used by the engine. | protected int | maxArrayLength Maximum collection and array length (along each dimension). | protected int | maxMkValSeqDepth Specify a maximum on the length of every generated mkVal
sequence. | protected int | maxShowDepth Maximum depth when showing objects in reporting. | protected int | numOfIrrelevantChecks In the current implementation the number of relevant checks is
a bit difficult to count; so we count instead the number of
irrelevant checks. | protected static String[] | optionsShortDesc Short descriptions of available options. | protected float | passTObjAsParamProb The probability for chosing to pass the target object as a
parameter rather than as a receiver object. | protected float | pickTargetObjFromPoolProb The probability that when a new execution is to be generated,
the target object will be picked from the pool rather than
created fresh with a constructor. | protected Random | rnd A random generator. |
baseDomain | protected BaseDomain baseDomain(Code) | | The base domain used by the engine.
|
chooseFieldUpdateProb | protected float chooseFieldUpdateProb(Code) | | The probability to do field update rather than method call.
Default is 0.1.
|
collectedTraces | protected LinkedList<Trace> collectedTraces(Code) | | Collected execution traces. Violating executions are collected
here, but future versions may add random traces to be
collected. When the engine is finished, collected traces are
saved and can be reloaded and replayed by a regression engine.
|
generateNullProb | protected float generateNullProb(Code) | | When trying to generate an instance of C, and one cannot be
found in the base domain, and the engine decided not to look in
the pool (hence generating a fresh one), this is the
probability of generating null. If less or equal to null, then
generating null in this way will be surpressed.
|
interfaceMap | protected InterfaceMap interfaceMap(Code) | | An interface map used by the engine. The map lists interfaces,
and for each possible concrete classes (currently juts one)
that implement it. When the engine needs to generate an
instance of an interface I, it first look it up in this
interface map. If the map says it has implementations, one
(say, C) will be selected and the engine will then proceed by
trying to generate an instance of C instead.
|
maxArrayLength | protected int maxArrayLength(Code) | | Maximum collection and array length (along each dimension). The
default is 4.
|
maxMkValSeqDepth | protected int maxMkValSeqDepth(Code) | | Specify a maximum on the length of every generated mkVal
sequence. Default is 4.
|
maxShowDepth | protected int maxShowDepth(Code) | | Maximum depth when showing objects in reporting. That is,
subobjects at deeper than this depth will not be shown. The
default is 5.
|
numOfIrrelevantChecks | protected int numOfIrrelevantChecks(Code) | | In the current implementation the number of relevant checks is
a bit difficult to count; so we count instead the number of
irrelevant checks.
|
optionsShortDesc | protected static String[] optionsShortDesc(Code) | | Short descriptions of available options.
|
passTObjAsParamProb | protected float passTObjAsParamProb(Code) | | The probability for chosing to pass the target object as a
parameter rather than as a receiver object. Default is 0.4.
|
pickTargetObjFromPoolProb | protected float pickTargetObjFromPoolProb(Code) | | The probability that when a new execution is to be generated,
the target object will be picked from the pool rather than
created fresh with a constructor. Default is 0.7.
|
RndEngine | public RndEngine(Class C, Pool p, BaseDomain dom, InterfaceMap imap)(Code) | | Create a test engine, with C as the target class, using the
given pool, base domain, and interface map.
|
RndTest | public static void RndTest(Class C, Pool p, BaseDomain dom, InterfaceMap imap, PrintStream out, String[] options) throws T2Exception(Code) | | A main Testing API; this static method will unleash
random testing on a given target class. Internally the method
creates a default test engine and uses it to test the class
C. Options can be passed to customize the engine; then the
engine is run. Violating executions will be reported and saved
in the file C.tr. The method terminates if the underlying test
engine throws a T2Error.
Parameters: C - The class to test. Passing null will print the usage info to the console. Parameters: p - An object pool to be used by the testing engine. Parameters: dom - A base domain to be used by the engine. Parameters: out - The (default) printstream to which the engine will send report. Parameters: options - Options to configure the engine before runningit; see the source code of printUsage in this class to seeavailable options. |
doesTargetClassConform | public static boolean doesTargetClassConform(Class C)(Code) | | Check if a given class is of the right kind (e.g. it is not an interface)
to be checked with this engine. It the class is not of the right,
messages will also be logged.
|
main | public static void main(String[] args)(Code) | | Just for testing this class.
|
printUsage | public static void printUsage(PrintStream out)(Code) | | Print usage help to the console.
|
report | public void report(PrintStream out)(Code) | | To report violating executions found by the engine.
|
runMe | public void runMe()(Code) | | The method to run the engine (that is, to run an automated
random testing).
|
|
|