节点文献

基于依赖性分析的面向对象程序测试技术研究

Research on Testing Technology of Object-oriented Programs Based on Dependency Analysis

【作者】 张艳梅

【导师】 姜淑娟;

【作者基本信息】 中国矿业大学 , 计算机应用技术, 2012, 博士

【摘要】 软件测试是保证软件质量的重要手段,是一项成本昂贵、耗时耗力的复杂工作。面向对象程序分为方法级、类级、类簇级和系统级四个测试级别。研究发现,方法级、类级测试(单元测试)和类簇级测试(集成测试)是软件测试中关键的研究领域。本论文分别针对类单元测试中的路径覆盖测试数据生成问题和集成测试中类测试顺序的确定问题,研究面向对象程序测试技术及应用。类中的方法与传统程序中的过程(或函数)有一定区别,因此,本论文首先对包含异常处理结构的面向对象程序进行类簇级依赖性分析,研究异常处理结构对依赖性信息所造成的影响,进而准确地分析出程序中的控制流、数据流、控制依赖、数据依赖等信息,为系统的结构测试等软件工程的任务提供准确的信息。在程序依赖性分析的基础上,提出基于条件语句相关性的不可达路径静态检测方法:首先给出基于数据流信息的条件语句相关性判定原理,再利用条件语句相关性检测程序的不可达路径。本方法的创新点在于考虑了异常处理结构和别名对数据流信息的影响。实例分析结果表明,该方法可以提高路径的可达性检测结果的精确度,为有效解决路径覆盖问题奠定了基础。在路径可达性检测的基础上,针对基于路径覆盖的测试数据生成问题,提出了多路径覆盖测试数据生成方法。该方法首先将被测程序表示成控制流图,对目标路径采用语句标号结合分支走向的方法表示成混合串;然后采用遗传算法,一次执行生成多条路径各自的测试数据,设计的适应度函数综合考虑个体穿越的路径与每个目标路径的匹配程度。实验结果表明,该方法避免了冗余测试,有效提高了测试数据生成效率。类测试顺序的确定是类簇级测试中的一个重点和难点问题。针对只考虑类间静态依赖关系的情况下集成测试中的类测试序生成问题,以要被创建的测试桩的总体复杂度作为问题的优化目标,提出一种基于耦合度量的类间集成测试顺序的确定方法。该方法将类间耦合度量与基于图的启发式算法相结合,其中,前者用于度量每一个测试桩的复杂度,后者用于在保证测试桩总体复杂度尽可能小的条件下打破环路。首先提出一种度量中使用的耦合权重的计算方法,对测试桩的复杂度进行新的耦合度量;然后提出一种用于打破环路的基于图的启发式算法。实验结果表明,较现有方法相比,总体复杂度有明显的降低,节约了测试成本。在类间静态依赖关系构成环路的情况下,考虑面向对象中动态绑定特性以及抽象类不可实例化等特点,以被创建的测试桩的总个数作为问题的优化目标,提出一种基于测试级的类测试顺序确定方法。首先分析类之间的静态依赖和动态依赖关系;然后提出边的删除规则以及消除由静态依赖关系和动态依赖关系形成的环路的算法,在消除环路过程中保证测试桩的数目尽可能少;在此基础上进一步提出测试顺序分配策略和算法,进而确定基于测试级的类测试序列;但是,抽象类不可实例化的特点使得一些测试级不可行,因此,我们对其做了进一步调整,得到所有可行的测试级。实验结果表明,该方法较其它方法相比,需要较少的测试桩。本研究提高了测试数据的生成效率,并实现了自动生成类测试顺序的目标,一定程度上丰富了软件测试理论,具有重要理论意义和实际应用价值。

【Abstract】 Software testing is an important mean to improve and guarantee software quality.It is an expensive, tedious and labor-intensive work. Object-oriented software testingmethod includes four levels: method level testing, class level testing, class clusterlevel testing/inter-class testing and system level testing. Studies show that methodlevel testing and class level testing (unit testing) and class cluster leveltesting/inter-class testing (integration testing) are key research areas in softwaretesting. Considering the characteristics of actual software under test, this paperinvestigates theories and applications of object-oriented programs, aiming atevolutionary generation problem of test data based on path coverage in unit testingand class-integration-test order determination problem in integration testing. The maincontents of the paper are listed as follows.Method level testing, methods in a class and the traditional procedures (orfunctions) have some differences in some situations. Therefore, this paper analyzesthe dependency information of object-oriented programs that containexception-handling constructs. Through studying the influence of exception-handlingconstruct on the program dependency information, we expect to obtain the accuratelyinformation such as control flow, data flow, control dependence and data dependenceinformation. They can provide accurate information for software engineering taskssuch as system architecture testing.On the basis of analyzing the dependency information, we propose a staticapproach to detecting infeasible basis path of programs with exception-handlingconstructs based on branch correlations of different conditional statements. First, wegive the judgment principles of correlation for conditional statement based ondataflow information, and then detect infeasible paths based on branch correlations ofdifferent conditional statements. The novelty of the dataflow information lies in thefact that it takes account of exception-handling constructs and pointer alias analysis.The results of case study show that the proposed method can further enhance theaccuracy of feasibility for the detected basis paths, laying a good foundation for us tosolve path covering problem efficiently.For the problem of test data generation based on path coverage, we propose amethod of multiple path coverage test data generation on the basis of determining thefeasibility of paths. First, the program under test is expressed as control flow graph, and the target paths are encoded into the form of combining statement label with flowdirection of branch (i.e. T and F); then, genetic alorithm is applied to generatemultiple test data, and the fitness function of an individual takes into account thematching degree of the traversed path and the target paths. The experimental resultsshow that the propose approach can avoid redundant test, improving the efficiency oftest data generation effectively.To solve the problem of determining class-integration-test order when only staticdependencies are considered and the overall complexity of created test stubs is takenas the optimization goal, we present an approach to determinng class-integration-testorder based on coupling measures. The technique combines inter-class couplingmeasurement and graph-based heuristic algorithm. The former is used to assess thecomplexity of each stub and the latter is used to break cycles with the minimumoverall complexity of stubbing. First, we propose a computing method of couplingweight used in coupling measure, by which each test stub complexity is reevaluated.Then, present an effective graph-based heuristic algorithm for breaking the cycles ofclass diagram. The experimental results show that our approach can make the overallstubbing complexity for breaking cycles reduced obviously, and lead to lowerintegration test cost.We also propose an approach to deal with class-integration-test order in thepresent of cyclic dependencies, in which both dynamic binding and abstract classesare taken into account. The number of created test stubs is taken as the optimizationgoal. First, inter-class static and dynamic dependencies are analyzed. Then, rules ofedge deletion are given, in addition, an algorithm of eliminating the cycles thatformed by static and dynamic dependency is presented, ensuring that the number oftest stubs is minimum. Furthermore, an integration testing order strategy and analgorithm are given, enabling class-integration-test order based on test-levelgeneration. However, abstract classes that cannot be instantiated make some testlevels infeasible. Therefore, we adjust the test order to make all of them feasible. Theproposed strategy needs less test stubs and can significantly improve test efficiencycompared to previous work.This research greatly enriched the theory of software testing, achieved the goalsof improving the efficiency of test data generation and automatically generating classtest order, therefore, it has great theoretical significance and practical applicationvalues.

节点文献中: 

本文链接的文献网络图示:

本文的引文网络