Use expectCall to specify that the method should be called during the
test and fail if it doesn't happen. Usually use setupCall to, um, setup
return values when a method is called, but we don't care if it is
called or what the paramaters are. Use the setup to get the code to work
so you can get on to whatever else it is you want to verify. This can
sometimes be useful if you want a single setup in a mock that will be
used in several different tests.
S.
Barry Kaplan wrote:
> When should expectCall vs setupCall be used? Seems the only differnce is
> that setupCall creates a new ExpectationValue (overriding the existing
> instance), were expectCall sets the value of the existing instace.
>
> -bk
>
> ----
> private ExpectationValue wasCalled;
>
> public MethodExpectation(String aName) {
> name = aName;
> initializeWasCalled();
> }
>
> public void expectCall(MockCall aCall) {
> mockCall = aCall;
> wasCalled.setExpected(true);
> }
>
> public void setupCall(MockCall aCall) {
> mockCall = aCall;
> initializeWasCalled();
> }
>
> private void initializeWasCalled() {
> wasCalled = new ExpectationValue(name + " was called");
|