白盒测试生成的自动隔离
Automated Isolation for White-box Test Generation
摘要:
上下文白盒测试生成是一种仅使用源代码或二进制代码自动选择测试输入的技术。然而,当将此类技术应用于复杂程序时,它们会遇到挑战。主要的挑战之一是处理被测单元的依赖关系。Objective.如果没有适当的操作,生成的测试无法覆盖源代码的所有部分,或者调用依赖项可能会导致意外的副作用(例如,文件系统或网络访问)。这些问题应该在保持白盒测试生成的优势的同时得到解决。法在本文中,我们提出了一个自动化的源代码转换方法,解决白盒测试生成的依赖性问题。这种技术通过创建一个参数化的沙箱来隔离测试的执行,这个沙箱包围着转换后的单元。我们使用Microsoft Pex作为测试生成器,在一个现成的工具中实现了这种方法,并在GitHub的10个开源项目上进行了评估,这些项目总共有超过38.000行代码。结果评估结果表明,如果缺乏隔离阻碍了白盒测试生成,那么我们的方法能够提供帮助:它增加了自动生成的测试所达到的代码覆盖率,同时减少了不必要的副作用。此外,我们的结果作为一个独特的基准测试生成性能的Microsoft Pex的开源项目。结论基于这些结果,我们的源代码转换可能有助于缓解白盒测试生成中的隔离问题,因为它增加了在这种情况下达到的覆盖率,同时保持了在隔离代码上生成的测试的实用性。
英文摘要:
Context. White-box test generation is a technique used for automatically selecting test inputs using only the source or binary code. However, such techniques encounter challenges when applying them to complex programs. One of the main challenges is handling the dependencies of the unit under test. Objective. Without proper actions, generated tests cannot cover all parts of the source code, or calling the dependencies may cause unexpected side effects (e.g., file system or network access). These issues should be tackled while maintaining the advantages of white-box test generation. Method. In this paper, we present an automated source code transformation approach tackling the dependency issue for white-box test generation. This technique isolates the test execution by creating a parameterized sandbox wrapped around the transformed unit. We implemented the approach in a ready-to-use tool using Microsoft Pex as a test generator, and evaluated it on 10 open-source projects from GitHub having more than 38.000 lines of code in total. Results. The results from the evaluation indicate that if the lack of isolation hinders white-box test generation, then our approach is able to help: it increases the code coverage reached by the automatically generated test, while it reduces unwanted side effects. Also, our results act as a unique baseline for the test generation performance of Microsoft Pex on open-source projects. Conclusion. Based on the results, our source code transformations might serve well for alleviating the isolation problem in white-box test generation as it increases the coverage reached in such situations, while maintaining the practical applicability of the tests generated on the isolated code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。