@inproceedings{676622bbfab746d5a2688166cb17ba74,
title = "Mocking Classes in Kotlin with Mockative",
abstract = "Unit testing is instrumental in enhancing code quality, documenting system behavior, and preventing regressions in contemporary software development. One of the current limitations of the most popular existing unit-testing frameworks for the Kotlin language (e.g., MockK and Mockito) is that they are inherently tied to the Java Virtual Machine (JVM), restricting their use to JVM-compatible environments. To overcome this limitation, in this paper we present an extended version of Mockative, a Kotlin-specific mocking framework designed to operate across multiple platforms beyond the JVM. While originally Mockative was limited to interface mocking, we have enhanced it to support class mocking and spying through the utilization of Kotlin Symbol Processing (KSP) and KotlinPoet libraries. We show that Mockative is a viable alternative to traditional JVM-bound frameworks, particularly in Kotlin/Native environments. Our extension can mock simple classes up to four times faster than MockK and Mockito, although it exhibits a marginal performance decline in scenarios involving classes with extensive method definitions.",
keywords = "Kotlin, Mock, Unit Testing",
author = "Abrahamsen, \{Kristian Degn\} and Jacopo Mauro",
year = "2025",
month = sep,
day = "9",
doi = "10.1007/978-3-032-04200-2\_2",
language = "English",
isbn = "978-3-032-04199-9",
series = "Lecture Notes in Computer Science",
publisher = "Springer Science+Business Media",
pages = "23--31",
editor = "Davide Taibi and Darja Smite",
booktitle = "Software Engineering and Advanced Applications",
address = "United States",
note = "51st Euromicro Conference on Software Engineering and Advanced Applications, SEAA 2025 ; Conference date: 10-09-2025 Through 12-09-2025",
}