提出了一种基于层次切片模型适合面向对象语言的错误定位方法.首先分别在包层、类层、方法层删去通过测试的包、类和方法,缩小软件错误存在的范围;其次,在语句层将删减后的程序按抽象语法树划分成若干模块,统计模块内变量使用的数目;通过动态分析,选取一组测试用例计算其执行历史;根据模块内使用变量数目的规模,采用逐步求精算法,计算产生错误测试用例的程序执行历史与静态分析过程中所产生模块的交集及交集的后向切片,直至实现错误定位.实验数据表明:该方法能够查出前期定位程序中绝大部分错误的位置,尤其适用在方法调用比较少的程序中.在方法调用比较频繁的程序中,由于在调用语句处迭代调用逐步求精算法,效率会降低.
A novel HSM(hierarchical slicing model)-based fault localization technique is proposed for object-oriented programs.Firstly,the scope of fault localization is reduced by deleting packages,classes and methods which have passed the tests,then the reduced program will be partitioned into some modules based on AST(abstract syntax tree) by analyzing statements,and further,the number of variables within each module are computed independently.Then,execution history is computed based on a set of test cases.Finally,according to the size of the variables used in the modules,the intersection of each module and its backward slice are iteratively calculated using the SSA(stepwise slicing algorithm) until faults are eventually localized.Experimental results show that: the method can locate the most faults early,especially in the program with less method calling relationship.The SSA is called iteratively in the program where the method is called more frequently.Thus,the efficiency is reduced.