Skip to content

Instantly share code, notes, and snippets.

@soudmaijer
Created February 5, 2018 13:33
Show Gist options
  • Save soudmaijer/d4cb0780e072fe61cd523752c7707e3f to your computer and use it in GitHub Desktop.
Save soudmaijer/d4cb0780e072fe61cd523752c7707e3f to your computer and use it in GitHub Desktop.
@RunWith(JMockit::class)
class AddressBookTestKt {
@Injectable
private lateinit var addressBookRepository: AddressBookRepository
@Tested
private lateinit var addressBook: AddressBook
@Test
fun retrieveAddressByIdTest() {
expectations {
// Instruct mocks
addressBookRepository.findById(1)
result = Address(1)
}
val address = addressBook.getAddressById(1)
Assert.assertNotNull(address)
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