Last active
February 5, 2018 12:54
-
-
Save soudmaijer/d4f422e021e9b66660033fbf2b27810f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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