UnitTestBot: Automated Unit Test Generation for C Code in Integrated Development Environments
Symbolic execution (SE) is one of the most promising techniques for automated unit test generation [1, 2], which is claimed to streamline the testing process and reduce developers’ effort [3]. There are symbolic execution engines [3] working for Java, C, C#, C++, Python, .NET. The KLEE dynamic symbolic execution engine is one of the most elaborated ones — it is built on top of the LLVM compiler infrastructure and can automatically generate inputs for C code unit testing [4]. There are numerous attempts to apply KLEE to real-life software projects [3, 5], while the industry experience still shows little transfer from research to practice [6]. The extensions to popular integrated development environments (IDEs) are supposed to be “breaking down this barrier” [7]. As far as there are not so many working tools like this, we share our experience of implementing the KLEE-based Visual Studio Code [8] and CLion [9] extensions for generating ready-to-use test cases — UnitTestBot for C code [10] — and describe the challenges we had to rise to. We also share the solutions we came up with: without introducing “new” techniques, we made automated unit test generation really automated and supplemented it with the simple wizard interface. That was enough for turning an effective but demanding technology into a user-friendly tool, which is easy to adopt. Finally, we provide examples of running UnitTestBot on the open-source projects as well as Huawei nonpublic code.