
Argument capturing in Mockk and Mockito. Writing tests for system under test (SUT) using Mockito. Writing tests for system under test (SUT) using Mockk. How to write unit tests in Kotlin projects. In this post, we’ll talk about each of them through the following sections: There are currently two popular frameworks built to aid in effective unit testing: Mockito and Mockk. Its concise and fancy language features have made it popular within the community, and it is being used frequently in projects such as Android applications, Kotlin Multiplatform Mobile (KMM) apps, and spring boot applications. The Kotlin programming language is fundamentally executed in the JVM environment. Encourage writing clean and maintainable code with less coupling. Serve as a good source of documentation for a developer to get insight on a project. Reduce code complexity by having a unit of code doing a specific thing.
Writing code to test code may seem counterintuitive, but it is an art unto itself that gives a developer confidence in their code.īelow are the significant benefits we derive from writing unit tests: Most successful software products use properly written unit tests fundamentally, unit testing verifies the correctness of a piece of code. Unit testing is an age-old integral part of the software engineering practice. I am a huge fan of clean code because clarity is King 😄 Unit testing in Kotlin projects with Mockk vs. Emmanuel Enya Follow I am a computer engineering graduate with five years of professional experience building modern Android applications.