一句话:提出 Genthat,从 R 程序执行轨迹非侵入式抽取单元测试,降低测试编写成本并提升覆盖率。
单元测试编写与维护成本高。本文研究从客户端代码执行轨迹中为软件包抽取单元测试的可行性,目标是在减少测试数量和体积的同时提高覆盖率。R 语言具有极端动态性、强制类型转换且缺乏类型系统,使传统测试抽取技术效果受限。作者提出非侵入式工具 Genthat,记录 R 程序执行轨迹并从中抽取单元测试。在 1,545 个包、约 170 万行 R 代码上评估:抽取测试将覆盖率从 267,496 行提升到 700,918 行,且生成测试运行时间比原始代码快 1.9 倍。
Unit tests are labor-intensive to write and maintain. This paper looks into how well unit tests for a target software package can be extracted from the execution traces of client code. Our objective is to reduce the effort involved in creating test suites while minimizing the number and size of individual tests, and maximizing coverage. To evaluate the viability of our approach, we select a challenging target for automated test extraction, namely R, a programming language that is popular for data science applications. The challenges presented by R are its extreme dynamism, coerciveness, and lack of types. This combination decrease the efficacy of traditional test extraction techniques. We present Genthat, a tool developed over the last couple of years to non-invasively record execution traces of R programs and extract unit tests from those traces. We have carried out an evaluation on 1,545 packages comprising 1.7M lines of R code. The tests extracted by Genthat improved code coverage from the original rather low value of 267,496 lines to 700,918 lines. The running time of the generated tests is 1.9 times faster than the code they came from