随机测试以其自动化程度高、揭错能力强的优势一直在测试用例的自动化生成领域占据着重要的地位,但其冗余度高、覆盖率低的缺陷限制了它的应用.程序不变量是程序的某个或某些特定的点上保持为真的属性,它可以提供程序运行时的有价值的信息.提出一种不变量指导下的随机测试用例的自动化生成方法.这种方法通过提取程序运行时的动态不变量,指导随机测试用例的生成,并且利用随机生成的无效用例的反馈信息,约简冗余的随机用例空间,增大了选中有效用例的概率.实验结果表明,该方法在保持随机测试的高揭错能力的前提下,可以有效的降低随机测试的冗余度,提高其覆盖率.
Random testing method occupies an important position in software testing for its high automation and the ability of finding software faults. However, the problem of high redundancy and low coverage limits the random testing method's application. A program invariant is an attribute which keeps true at one or some points of a program. It can provide valuable information about the running program. In this paper, we propose a method that generates test cases automatically under the guidance of program invariants. By getting dynamic program invariants during the program running, the method guides the generation of random test cases and reduces the useless random space according to the useless test cases generated before, and increases the probability of selecting effective test cases. Experiment results show that, on the basis of not reducing the ability of finding software fault of random testing, the method can effectively reduce redundancy and improve the coverage.