Automated unit test generation for classes with environment dependencies

Automated unit test generation for classes with environment dependencies
复制标题

DOI:
10.1145/2642937.2642986
复制
发表时间:
2014-09
期刊:
Proceedings of the 29th ACM/IEEE International Conference on Automated Software Engineering
影响因子:
--
通讯作者:
Andrea Arcuri;G. Fraser;Juan P. Galeotti
Andrea Arcuri;G. Fraser;Juan P. Galeotti
中科院分区:
其他
文献类型:
--
作者:
Andrea Arcuri;G. Fraser;Juan P. Galeotti

文献摘要

被引文献

相似文献

面向对象的软件的自动测试生成通常包括生成针对高码覆盖范围的调用序列。实际上,当类与他们的环境(例如文件系统,网络,用户互动等)相互作用时,此过程的成功可能会被抑制。这导致了两个主要问题:首先,取决于环境的代码有时无法仅通过生成对正在测试的类的呼叫的序列来完全覆盖,例如,当分支的执行取决于文件的内容时。其次,即使可以涵盖与环境相关的代码,结果测试可能是不稳定的,即,在第一次生成时它们会通过,但是在其他环境中执行时可能会失败。例如,如果测试在与生成时不同的时间执行,则使用系统时间的类测试可能会失败。在本文中,我们将字节件仪器应用于自动将代码与其环境依赖性分开,并扩展EvoSuite Java测试生成工具,以便它可以明确设置环境状态作为其生成的调用序列的一部分。使用原型实现,该实现处理了多种环境交互,例如文件系统,控制台输入和Java虚拟机的许多非确定性功能,我们对从SourceForge随机选择的100个Java项目进行了实验(SF100语料库)。结果表明,即使在+80%/ +90%的顺序上,在某些情况下,代码覆盖率得到了显着改善。此外,我们的技术将不稳定测试的数量减少了50%以上。
Automated test generation for object-oriented software typically consists of producing sequences of calls aiming at high code coverage. In practice, the success of this process may be inhibited when classes interact with their environment, such as the file system, network, user-interactions, etc. This leads to two major problems: First, code that depends on the environment can sometimes not be fully covered simply by generating sequences of calls to a class under test, for example when execution of a branch depends on the contents of a file. Second, even if code that is environment-dependent can be covered, the resulting tests may be unstable, i.e., they would pass when first generated, but then may fail when executed in a different environment. For example, tests on classes that make use of the system time may have failing assertions if the tests are executed at a different time than when they were generated. In this paper, we apply bytecode instrumentation to automatically separate code from its environmental dependencies, and extend the EvoSuite Java test generation tool such that it can explicitly set the state of the environment as part of the sequences of calls it generates. Using a prototype implementation, which handles a wide range of environmental interactions such as the file system, console inputs and many non-deterministic functions of the Java virtual machine (JVM), we performed experiments on 100 Java projects randomly selected from SourceForge (the SF100 corpus). The results show significantly improved code coverage - in some cases even in the order of +80%/+90%. Furthermore, our techniques reduce the number of unstable tests by more than 50%.