Envelope/Quill MockObjectsCodingStyle

- Last edited October 17, 2000
TimM proposed a discussion on ExpectationObject's and whether they need a flag for verification only on an expectation being set. During XtC10102000 we came up with a MockObjectsCodingStyle.

The initial options we came up were:

  1. don't try to be too pure. Put the flag in the ExpectationObject and set it.
  2. if there aren't many cases, move the flag to the MockObject, and keep the ExpectationObject's clean.
  3. "You don't need it - this is a CodeSmell?" JohnNolan suggested that this might be because one of your objects need splitting

In the end, inspired by a suggestion from CharlesWeir and some of the correspondence on Egroups, we came up with a working compromise:

The unit test code should now look something like:

  public void testMethod() {
    MockThingy? thingy = new MockThingy?();
    thingy.myFoo.setExpected(new First());
    thingy.myBar.setExpected(new Second());
    thingy.myBlob.doNotVerify();

myTarget.doTheThing(thingy); thingy.verify(); // only verifies thingy.myFoo and thingy.myBar, not thingy.myBlob }

- Last edited October 17, 2000

https://casino-brain.com/