Wrapping Up

Automated testing is a key technical practice for sustainable agile development. You may use tools that you’re used to in Java to write automated tests for Kotlin. Alternatively, you may use tools that are targeted specifically for Kotlin, to enjoy fluency and to be able to use idiomatic Kotlin style. In this chapter, we used KotlinTest, Mockk, and Jacoco to write tests, to mock dependencies, and create the code coverage report. In addition, we used Gradle and Maven to run the builds.

KotlinTest provides elegant syntax and fluent asserts, along with many different options to write tests. Mockk is a powerful mocking tool that can be used to stub and mock classes, singletons, companion objects, and top-level functions. Mockk also has ...

Get Programming Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.