Unit testing made easy with MockK
July 22, 2021 4:20 PM 4:50 PM ONLINE
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, capturing and replaying arguments, relaxed mocking, top-level functions)
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.