Kotsuite: Unit Test Generation for Kotlin Programs in Android Applications
Feng Yang, Xin Qi, Zhilei Ren, Jifeng Xuan · 2025
Unit testing plays a pivotal role in safeguarding functional requirements and supporting the maintenance during the development of Android applications. The Kotlin programming language emerges in developing Android applications due to its simplicity, safety, and interoperability with Java. It is timeconsuming to manually write unit test cases for Kotlin programs. To mitigate labor costs, automated unit test generation techniques are developed. However, existing tools of unit test generation, such as EvoSuite and Randoop, are primarily optimized for traditional Java projects. This makes these tools incapable of generating test cases for Kotlin projects in Android. In this paper, we introduce KotSuite, an automated tool of unit test generation for Kotlin applications in Android. KotSuite employs static analysis techniques to extract the syntactic structure of the target methods and transforms the syntactic structure into the control flow representation. Then, KotSuite automatically generates a suite of test cases using a genetic algorithm and test reuse. We evaluate KotSuite on eight modules from four widely-used and opensource Kotlin projects in Android. Experimental results show that KotSuite can effectively generate high-coverage test cases with average line coverage of 66.0 % and branch coverage of 60.4%.