@Spy
UniqueCharacterCounterService spy = spy(new UniqueCharacterCounterService());
@Test
public void testCache() throws IncorrectInputDataException {
spy.countCharacters("Hello");
verify(spy).count("Hello");
spy.countCharacters("world");
verify(spy).count("world");
spy.countCharacters("Hello");
spy.countCharacters("world");
verify(spy, atLeastOnce()).count("Hello");
}
I have this test.And i need to be sure that method called at once(at the first situation).And at other calls just retuns cached values , so the method doesn`t call.
Aucun commentaire:
Enregistrer un commentaire