randoop
Interface Check

All Superinterfaces:
Serializable
All Known Implementing Classes:
ExpectedExceptionCheck, NoExceptionCheck, ObjectCheck

public interface Check
extends Serializable

A correctness check performed on some aspect of a unit test's execution. Examples include assertions, calls to invariant or "checkRep" methods, or try-catch clauses that check for expected exceptions.

Check objects are inserted as a decorations on specific indices of an ExecutableSequence. Thus, a check is always associated with a specific index in a sequence. A check at index i means that the check is to performed after statement i finishes executing.

A check implements two methods that specify the code to be emitted before and/or after a statement in a Sequence is executed.

A check may require some code to be emitted before and/or after the statement is printed. For example, a check for checking that x is not null after the statement "Foo x = m()" is executed might emit the assertion code "assertNotNull(x);", and would do so after the statement is printed. As a second example, a check for checking that an expected exception is thrown by a statement would need to emit something like "try {" before the statement, and the catch clause after the statement.

Checks are Serializable so that an ExecutableSequence can be serialized along with its associated checks.


Method Summary
Modifier and Type Method and Description
 boolean evaluate(Execution execution)
          Evaluates this check on the given unfolding execution of a sequence, returning true if the check succeeded, and false otherwise.
 String get_id()
          Returns a unique string identifier for the check.
 int get_stmt_no()
          Returns the offset in the sequence of this check
 String get_value()
          Returns a short string that can be used to uniquely identify this check.
 String toCodeStringPostStatement()
          Returns a string of Java source code to be emitted after a statement containing this check.
 String toCodeStringPreStatement()
          Returns a string of Java source code to be emitted before a statement containing this check.
 

Method Detail

toCodeStringPreStatement

String toCodeStringPreStatement()
Returns a string of Java source code to be emitted before a statement containing this check.


toCodeStringPostStatement

String toCodeStringPostStatement()
Returns a string of Java source code to be emitted after a statement containing this check.


get_value

String get_value()
Returns a short string that can be used to uniquely identify this check.


get_id

String get_id()
Returns a unique string identifier for the check. Two checks are the same if these identifers match. The value is NOT included. with. Used to match up checks between the same sequence run at different times. Note that because of changes in the environment (eg, static variables), two executions of the same sequence may have different checks (because the existence of some checks depends on the value of variables)


get_stmt_no

int get_stmt_no()
Returns the offset in the sequence of this check


evaluate

boolean evaluate(Execution execution)
Evaluates this check on the given unfolding execution of a sequence, returning true if the check succeeded, and false otherwise.