|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ObjectContract extends Serializable
An object contract provides the core functionality for the checking code of unit tests, i.e. the code that checks for expected behavior. An object contract checks a specific property for one or more objects. Implementing classes provide two key pieces functionality:
evaluate(Object... objects) that
evaluates ones or more objects at runtime and determines if the
given object(s) satisfy the property. The arity will depend
on the specific property being checked.
toCodeString() that emits Java code
that can be inserted into a unit test to check for the given
property.
Randoop outputs sequences that lead to failing properties as error-revealing test cases.
See the various implementing classes for examples
(for an example, see the EqualsReflexive).
| Modifier and Type | Method and Description |
|---|---|
boolean |
evalExceptionMeansFailure()
Communicates to Randoop how to interpret exceptional behavior from the evaluate method. |
boolean |
evaluate(Object... objects)
Evaluates the contract on the given values. |
String |
get_observer_str()
Returns a string describing the observer |
int |
getArity()
The number of values that this contract is over. |
String |
toCodeString()
A string that can be used as Java source code and will result in the expression being evaluated. |
String |
toCommentString()
A string that will be inserted as a comment in the test before the code corresponding to this contract. |
| Method Detail |
|---|
int getArity()
boolean evaluate(Object... objects)
throws Throwable
When calling this method during execution of a test, Randoop
guarantees that objects does not contain any
null objects, and that
objects.length == getArity().
This method should return true if the contract was
satisfied and false if it was violated.
Throwableboolean evalExceptionMeansFailure()
evaluate method.
If this method returns true, Randoop will interpret
an exception that escapes during evaluation as a failure of the
contract.
If the method returns false, Randoop will interpret
an exception as passing behavior.
String toCommentString()
String toCodeString()
The string should be formatted as follows: the N-th object that participates in the contract check should be referred to as "xN" (for N one of 0, ... , 9). For example, if the expression or arity 2 represents a call of the equals method between two objects, the comment should be something like "x0.equals(x1)".
The returned string should not be null.
String get_observer_str()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||