Unit testing made easy with MockK

Monika Kumar Jethani

Android engineer

Walmart Global Tech

Mockito has been used in testing kotlin/android apps since long, however there is setup required and a lot of boilerplate code required to test certain kotlin components as well as a need to use other libraries like PowerMock for the features that Mockito doesn’t support. Mockk, a mocking framework with first-class support for kotlin features, comes to the rescue and helps developers write unit tests easily as well as improve code coverage without having to do extra setup/ write boilerplate code or use other mocking frameworks.

In this session, we will look at codebase of an android app and learn the following,
1- how mockk can help us test the various application components(objects, classes, enums, constructors, chaining calls, hierarchial mocking, verification order, extension functions, coroutines, deferred and suspending functions, private and static functions, methods where callback is an argument, exceptions, capturing and replaying arguments, relaxed mocking)
2- how mockk is better than mockito in testing 1
3- which is better for code coverage - mockk vs mockito

By the end of this session, the attendees will have good knowledge about mockk and will be prepared to use mockk in their projects.

Monika is an Android engineer having 6 years of experience in IT. She is currently working at Walmart Labs India and is a regular Android/Kotlin speaker at mobile development conferences/meetups. She writes code, reads code and speaks about code. Last, but not the least, she shares her birthday with Java :)

droidcon APAC is produced by:

Mobile Seasons GmbH (droidcon Global HQ)

Messedamm 22

14055, Berlin


.droidcon is a registered Trademark of Mobile Seasons GmbH

  • dc-social
  • Twitter - White Circle
  • Facebook - White Circle