计算机科学与探索 ›› 2015, Vol. 9 ›› Issue (12): 1450-1458.DOI: 10.3778/j.issn.1673-9418.1504032

• 系统软件与软件工程 • 上一篇    下一篇

针对方法声明演化的单元测试用例修复方法

张琼宇,杨秋辉+,张光渝,程雪梅,孙  琳   

  1. 四川大学 计算机学院,成都 610065
  • 出版日期:2015-12-01 发布日期:2015-12-04

Repairing Unit Test Cases for Evolving Method Declarations

ZHANG Qiongyu, YANG Qiuhui+, ZHANG Guangyu, CHENG Xuemei, SUN Lin   

  1. College of Computer Science, Sichuan University, Chengdu 610065, China
  • Online:2015-12-01 Published:2015-12-04

摘要: 软件演化会造成一部分测试用例失效,如果直接将其从测试用例集中移除,会影响测试用例集检测缺陷的能力,降低回归测试的有效性。测试用例修复技术可以减少测试维护的工作量,增强回归测试的有效性。研究了针对方法声明演化的单元测试用例修复方法,首先使用反射机制得到方法声明演化信息,识别演化类型,再针对方法名称改变、方法参数改变和返回参数类型改变,分别提出了相应的修复策略。在修复过程中使用动态符号化执行技术得到测试数据,提高了测试用例修复的范围。实验表明,该方法能有效修复由方法声明演化引起编译错误的测试用例,平均修复率为60%左右,证明了该方法的可行性。

关键词: 单元测试用例修复, 方法声明演化, 反射机制, 符号化执行

Abstract: Some of test cases may become obsolete because of software system evolution. Discarding these test cases will weaken fault detection ability, and reduce the effectiveness of regression testing. Automatically repairing test cases can reduce the maintenance workload of developers, and improve the efficiency of regression testing. This paper proposes a method for automatically repairing test cases that become obsolete because of the changes in method declarations. Firstly, the information of method declaration changes is got by using reflection mechanism. Then, the declaration change types, such as method name change, method parameters change and method return type change, are identified. Finally, different repairing strategies are put forward for different declaration change types. When repairing test cases, some of test data are obtained by using dynamic symbolic execution tool, which can expand the range of test case repairing. The experiment shows that the proposed method can repair nearly 60% obsolete test cases because of method declaration change, this proves the feasibility of the proposed method.

Key words: unit test case repairing, method declaration evolving, reflection mechanism, symbolic execution