I am using Jmockit for the firs time so I could be missing something trivial. I have a method under test addTopTenListsTest() which calls --> mockObjectifyInstance.save().entity(topTenList).now();
Objectify is mocked, however when I comment out the mockObjectifyInstance.save() call from the Expectations() (Strict Expectation) (shown in code block below) the test case still goes green. I was expecting the test case to fail, since a call would be made on a mocked object that is not listed in the Strict expectation.
Any suggestions?
@RunWith(JMockit.class)
public class DataManagerTest {
@Mocked
ObjectifyService mockObjectifyServiceInstance;
@Mocked
Objectify mockObjectifyInstance;
@Test
public void addTopTenListsTest() {
final TopTenList topTenList = new TopTenList();
new Expectations() {
{
ObjectifyService.ofy();
result = mockObjectifyInstance;
// mockObjectifyInstance.save().entity(topTenList).now(); --> expected test case to fail when this is commented out
}
};
DataManager datamanager = new DataManager();
datamanager.addTopTenList(topTenList);
new Verifications() {{
mockObjectifyInstance.save().entity(topTenList).now();
}};
}
}