摘要 针对目前面向对象软件的测试方法较少且效率不高的问题,提出将基于ART(adaptive random testing)思想的限制性随机测试RRT(restricted random testing)应用到面向对象程序中的方法.分析了面向对象软件测试用例的结构,提出了测试用例包含动态部分和静态部分.确定测试用例之间的距离为动态部分和静态部分的距离和,并分别给出了这2个距离的计算公式.设计了基于RRT的测试原型系统,该原型系统主要的功能模块有类图录入模块、测试用例距离度量模块、基于RRT测试用例生成模块、结果分析模块.通过试验对比了文中方法与随机测试方法.结果表明,文中提出面向对象的RRT方法在发现第1个程序错误的测试中比随机测试方法减少了约50%的测试用例数量,且在发现测试用例的质量上也几乎与随机测试相同.文中提出的测试用例度量机制能够有效地对面向对象软件中的测试用例进行区分,基于RRT的测试原型系统也能自动化地生成测试用例并自动测试从而大大提高了面向对象软件测试的效率.
Abstract: To solve the problems that the current testing methods for object-oriented software are less and inefficient, an approach of restricted random testing (RRT) was proposed based on adaptive random testing (ART) for object-oriented programs. The structure of object-oriented software test cases was analyzed, and the test cases were suggested with dynamic part and static part. The distance between the test cases was given as the distance between the dynamic part and the static part, and the formulas for calculating the distance between the dynamic part and the static part were given respectively. A prototype system was designed based on RRT. The main modules of the prototype system were class diagram entry module, test case distance measurement module, RRT test cases generation module and result analysis module. The proposed method was compared with random testing method by experiments. The results show that compared with the random test method, the proposed object-oriented RRT method can reduce the number of test cases by about 50% in detecting the first program error, and the quality of the test cases is almost the same as the random testing. The proposed test case measurement mechanism can effectively distinguish test cases in object-oriented software. The RRT-based test prototype system can also automatically generate test cases and automatically test the software, which greatly improves the efficiency of object-oriented software testing.