arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2103.07006cs.SE
收藏

使用相对代码行指导Python自动测试生成

Using Relative Lines of Code to Guide Automated Test Generation for Python

Josie Holmes, Iftekhar Ahmed, Caius Brindescu, Rahul Gopinath, He Zhang, Alex Groce

摘要:

原始代码行(Raw Lines of Code,简写为Raw)是一个度量标准,乍一看,它似乎对自动化测试生成并不十分有用。它高度依赖于语言,在语义上,在一种语言中并不是非常有意义:一个编码器可以用比另一个编码器少得多的行来产生同样的效果。然而,同一项目的组件之间的相对一致性,被证明是自动化测试的一个非常有用的度量。在本文中,我们利用一个启发式的基础上的测试功能的计数,以显着提高自动测试生成的有效性。这种方法在收集代码覆盖率数据来指导测试的语言中特别有价值。我们使用TSTL(模板脚本测试语言)工具将启发式应用于基于属性的Python测试。在我们的实验中,简单的启发式算法可以大幅提高分支和语句覆盖率(通常超过20%,最高可达40%或更多),并提高故障检测率(通常超过75%,最高可达400%或更多)。该启发式也很容易与其他方法相结合,并且可以与两种用于指导随机测试的成熟方法相媲美,并且可能更有效。

英文摘要:

Raw lines of code (LOC) is a metric that does not, at first glance, seem extremely useful for automated test generation. It is both highly language-dependent and not extremely meaningful, semantically, within a language: one coder can produce the same effect with many fewer lines than another. However, relative LOC, between components of the same project, turns out to be a highly useful metric for automated testing. In this paper, we make use of a heuristic based on LOC counts for tested functions to dramatically improve the effectiveness of automated test generation. This approach is particularly valuable in languages where collecting code coverage data to guide testing has a very high overhead.We apply the heuristic to property-based Python testing using the TSTL (Template Scripting Testing Language) tool. In our experiments, the simple LOC heuristic can improve branch and statement coverage by large margins (often more than 20%, up to 40% or more), and improve fault detection by an even larger margin (usually more than 75%, and up to 400% or more). The LOC heuristic is also easy to combine with other approaches, and is comparable to, and possibly more effective than, two well-established approaches for guiding random testing.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑