JMock-Verify+Method+Called+Exactly+Once

<--Back

Verify a sequence of methods
This test method exists in a jMock JUnit 4 Die Skeleton.

Make sure that the testDoubleDie method will first have its roll method called exactly once and then its getFaceValue method called exactly once:

code format="java5" @Test public void rollThenGetFaceValue { context.checking(new Expectations {       {            one(testDoubleDie).roll;            one(testDoubleDie).getFaceValue;        }    }); testDoubleDie.roll; testDoubleDie.getFaceValue; } code

code format="java5" Withdrawal withdrawal; Mockery context = new Mockery;
 * Common fixture for the test**

BankAccount account;

@Before public void initialize { withdrawal = new Withdrawal; withdrawal.setAmount(1500); account = context.mock(BankAccount.class); withdrawal.setAccount(account); } code

<--Back