-
Notifications
You must be signed in to change notification settings - Fork 68
Stubbing
Markus Amshove edited this page Feb 21, 2016
·
3 revisions
This file contains examples on supported methods for mocking. All methods use Mockito.
Further examples can be seen in the tests
val mock = mock(Database::class)
val bob = Person("Bob", "Guy")
When calling mock.getPerson() itReturns bob
When calling mock.getPerson() itThrows RuntimeException("An exception")
var counter = 0
When calling mock.getPerson() itAnswers {a -> counter++; alice}
mock.getPerson()
assertEquals(1, counter)