Interface Expectation

All Superinterfaces:
Verifiable
All Known Subinterfaces:
ExpectationCollection
All Known Implementing Classes:
AbstractExpectation, AbstractExpectationCollection, ExpectationCounter, ExpectationDoubleValue, ExpectationList, ExpectationMap, ExpectationSegment, ExpectationSet, ExpectationValue

public interface Expectation extends Verifiable
An Expectation is an object that we set up at the beginning of a unit test to expect certain things to happen to it. If it is possible to tell, the Expectation will fail as soon as an incorrect value has been set.

Call verify() at the end of a unit test to check for missing or incomplete values.

If no expectations have been set on the object, then no checking will be done and verify() will do nothing.

Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Return true if any expectations have been set on this object.
    void
    Tell the object to expect nothing to happen to it, perhaps because the test is exercising the handling of an error.
    void
    If an incorrect actual value is set, defer reporting this as a failure until verify() is called on this object.

    Methods inherited from interface org.jmock.core.Verifiable

    verify
  • Method Details

    • hasExpectations

      boolean hasExpectations()
      Return true if any expectations have been set on this object.
    • setExpectNothing

      void setExpectNothing()
      Tell the object to expect nothing to happen to it, perhaps because the test is exercising the handling of an error. The Expectation will fail if any actual values are set.

      Note that this is not the same as not setting any expectations, in which case verify() will do nothing.

    • setFailOnVerify

      void setFailOnVerify()
      If an incorrect actual value is set, defer reporting this as a failure until verify() is called on this object.