I\'m confused as to the purpose of and difference between expectations and verifications. E.g.
@Tested FooServiceImpl fooService;
@Injectable FooDao fooDao;
@Te
The purpose of Expectations
is to allow a test to record expected results for mocked methods and/or constructors, as needed by the code under test.
The purpose of Verifications
is to allow a test to verify expected invocations to mocked methods and/or constructors, as made by the code under test.
So, normally, a test wouldn't both record and verify the same expectation (where an "expectation" specifies a set of invocations to mocked methods/constructors that are expected to occur when the code under test is exercised).
With that in mind, the example test would look like this:
@Tested FooServiceImpl fooService;
@Injectable FooDao fooDao;
@Test
public void callsFooDaoDelete() throws Exception {
fooService.delete(1L);
new Verifications() {{ fooDao.delete(1L); }};
}