@Test public void verifyAllInvocationsToOneOfTwoMocksInIteratingBlock(AnotherDependency mock2) { mock2.doSomething(); mock.setSomething(123); mock.save(); mock2.doSomethingElse(1); mock.setSomething(45); mock.save(); mock2.doSomethingElse(2); new FullVerifications(2, mock) { { mock.setSomething(anyInt); mock.save(); } }; }
@Test public void importMockInReusableVerificationBlock() { new ReusableExpectations() {}; dependency.notifyBeforeSave(); dependency.save(); new ReusableVerifications() {}; }
@Test public void importMockFromReusableExpectationBlock() { new ReusableExpectations() {}; dependency.notifyBeforeSave(); dependency.save(); new VerificationsInOrder() { Dependency dep; { dep.notifyBeforeSave(); unverifiedInvocations(); } }; }
@Test public void verifyNoInvocationsOnOneOfTwoMockedDependenciesBeyondThoseRecordedAsExpected( final AnotherDependency mock2) { new NonStrictExpectations() { { mock.setSomething(anyInt); minTimes = 1; mock2.doSomething(); times = 1; } }; mock.prepare(); mock.setSomething(1); mock.setSomething(2); mock.save(); mock2.doSomething(); new FullVerifications(mock2) {}; }
{ mock.save(); maxTimes = 1; }
private void exerciseCodeUnderTest() { mock.prepare(); mock.setSomething(123); mock.editABunchMoreStuff(); mock.save(); }