Last active
February 5, 2018 12:55
-
-
Save soudmaijer/4c2f1af25b2d29c240a6d4ed81c0f744 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) | |
class AddressBookTest { | |
@Injectable | |
private lateinit var addressBookRepository: AddressBookRepository | |
@Tested | |
private lateinit var addressBook: AddressBook | |
@Test | |
fun retrieveAddressByIdTest() { | |
object : Expectations() { | |
init { | |
// Instruct mocks | |
addressBookRepository.findById(1) | |
result = Address(1) | |
} | |
} | |
val address = addressBook.getAddressById(1) | |
Assert.assertNotNull(address) | |
object : Verifications() { | |
init { | |
// 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