Instantly share code, notes, and snippets.

Embed
What would you like to do?
@RunWith(JMockit.class)
public class AddressBookTest {
@Injectable
private AddressBookRepository addressBookRepository;
@Tested
private AddressBook addressBook;
@Test
public void retrieveAddressByIdTest() {
new Expectations() {{
// Instruct mocks
addressBookRepository.findById(1);
result = new Address(1);
}};
Address address = addressBook.getAddressById(1);
Assert.assertNotNull(address);
new Verifications() {{
// Verify behaviour
addressBookRepository.findById(1);
times = 1;
}};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment