Mocking Mocking Mocking start with one call, the mockk function. This function takes in a class and returns a fake version of it, where all functions are present but will throw...
Android Quickstart Android Quickstart MockK works great with Android and allows you to mock objects in both your Android unit tests and instrumented tests. MockK can handle mock...
Coroutines and suspend functions Coroutines and suspend functions As MockK uses function literals to create stubs, small changes are needed to stub suspend functions. MockK prov...
Mock singleton objects and static methods Mocking objects Mocking static methods Unmocking Mock singleton objects and static methods Mocking objects When you need a singleto...
void methods void methods Mockito’s when method doesn’t work with void methods. To create a stub that doesn’t return anything, the doNothing method is used. val mockedFile...
Migrating from Mockito Migrating from Mockito Learn how to use MockK by seeing equivalents to functions in Mockito . Create a mock The similarities and differences in creatin...
argThat argThat The argThat argument matcher in Mockito lets you create advanced argument matchers that run a function on passed arguments, and checks if the function returns...
Return Unit Return Unit When stubbing a function that returns nothing, MockK provides a few shortcuts. val logger = mockk < Logger >() every { logger . log ( any ())...
Side effects Answer scope Individual arguments All arguments Most stubs will use returns to always return the same value when the corresponding method is called. Sometimes, ...