节点文献

面向对象程序分析与测试技术研究

Research on Analysis and Testing Techniques of Object-Oriented Programs

【作者】 毛澄映

【导师】 卢炎生;

【作者基本信息】 华中科技大学 , 计算机软件与理论, 2006, 博士

【摘要】 在软件生命周期过程中,软件测试是保证软件质量的关键环节之一。面向对象方法学在软件工程中的引入极大地方便了软件的设计、开发和维护,为创建高可靠性的软件系统提供了重要保证,但面向对象程序的封装、继承、多态和异常处理机制等新特性却给测试带来新的挑战。一方面需要调整、改进传统的测试策略和方法;另一方面探索出适应面向对象程序特征的测试理论与技术也尤为必要。面向对象软件测试分为方法级、类级、类簇级和系统级四个级别。就方法级测试而言,类中的方法与传统程序中的过程(或函数)并无太大区别,所以用于传统程序的控制流或数据流等结构性测试方法可以调整用于类中方法内或方法间的测试,其中的分支覆盖准则被实践证明是其中性价比最高的一种策略。运用DD图表示程序的控制流,并在此基础上分析程序的依赖关系及DD图的性质,提出了一种近似求解控制依赖关系中非约束边集的算法Find_SemiUE,虽然精度有所降低,但该方法简便、快捷且适合于大规模程序的处理。基于非约束边集,对DD图进行正(逆)向广度(深度)优先搜索形成生成树并用逆邻接表表示,给出了一种以较小的时空开销生成分支测试路径用例集的简化算法Generate_PathSet。类是面向对象程序的基本单元,只有对类进行充分的测试才能确保高层测试简便且可信,从而降低整个测试过程的代价。统计测试方法由于简便、快捷和低成本等特性已被广泛用于测试活动中,并被实践证明较确定性测试方法有更强的缺陷暴露能力。针对面向对象程序特征和不同的理解视角,从方法级和对象级运用统计测试技术对类程序进行测试。方法级统计结构性测试主要是在分析类控制流图的基础上,通过执行能统计覆盖程序路径的用例集来揭示类中语句的逻辑错误。对象级统计功能性测试则是利用类程序需求和操作剖面进行建模,再运行由方法序列构成的用例来检查错误的实现和遗漏缺陷等。最后,将两个级别的测试有机地结合在一起形成一个混合统计测试框架。类间测试序的确定是类簇级测试中的一个难点。对传统的对象关系图进行扩展,运用EORD图和WORD图对类间的继承、聚集和关联三种关系进行建模表示,以“生成的存根数目最少”为优化目标,利用成环权重、边向因子和联系强度等启发式规则,给出了一种高效、准确的类间测试序确定算法ICTO。该算法具有递归次数少、能降低测试桩(存根)的生成代价以及稳定性好等优点。面向对象技术为构件的实现提供了基本技术支持,对构件软件的测试可以看作是面向对象程序测试的扩展和延伸。由于对构件内部结构及其变更信息缺乏了解,使得构件使用者测试构件软件系统异常困难,对回归测试来讲则更为突出。其主要原因是难以选择出与变更相关的用例用于测试由新版构件构建的系统。分析已有回归测试技术的不足,基于方便构件使用者获取构件结构及其变更信息的思路,提出了两种改进的构件软件回归测试策略:一种是基于增强的构件版本变更信息的方法;另一种则是基于内建式测试设计的方法。通过对几个实例程序的实验分析,证实了所提出的方法在实际应用中的可行性与有效性。软件测试应是“理论+技术+辅助工具+管理”的结合体,辅助测试工具在其中起着举足轻重的作用。以目前普遍使用的C/C++程序作为测试对象,实现了一个能进行方法级、类(簇)级和系统级三个级别测试的原型系统CppTest:基于程序CFG图分析、探针插装和I/O重定向等技术,实现方法级结构性测试;按照需求规约运用EFSM对类的状态转换行为进行建模,并依此自动生成测试用例集,实现基于状态的类测试;在系统级别上,运用等价类划分、边界值分析等常规策略进行黑盒测试。此外,运用聚类技术对失效执行进行聚类分析,并从中抽样出典型的测试执行用例用于指导程序的进一步诊断。CppTest具备多级别测试、测试项目化管理、自动化/可视化程度高、扩展性好等优点。

【Abstract】 During the whole lifecycle of software development, software testing is one of the key steps to ensure the high quality of software. The introduction of Object-Oriented methodology into software engineering greatly facilitates the processes of software design, development and maintenance, but some characters of Object-Oriented programs, such as encapsulation, inheritance, polymorphism, and exception handling mechanism, bring some new challenging problems to software testing. Some traditional testing strategies and methods can be adjusted or improved for testing the OO programs. On the other hand, exploiting a new system of testing theory and technology for these new specialties is essentially important.Object-Oriented software testing can be classified into four different levels: method level, class level, cluster level, and system level. There is no significant difference between the methods in class and the procedures (or functions) in traditional program, thus the common structural testing methods, such as control flow or data flow testing, can be applied into intra-/inter-method testing in class, and the branch coverage criterion has been proved to be the best cost performance of its all criteria. Based on analyzing the dependency of program constructs and properties of Decision-to-Decision graph, which is a representation of program’s control flow, an approximate algorithm (called Find_ SemiUE) for solving the set of unconstrained edges (i.e., UE) is proposed, which is simple, quick and very suitable for the large-scale programs. Under the direction of UE, a simplified algorithm named Generate_PathSet can generate the test path cases with low time and space cost via forward (backward) breadth (depth) traversal of DD graph.Statistical testing approach has been proved to be with stronger fault revealing power than deterministic testing method in practice. With its remarkable characters of simplicity, convenience, and lower cost, it has been diffusely adopted in software testing activities. Aiming at OO program’s specialties and different comprehension perspectives, the statistical testing in method level and object level can be employed on class programs respectively. The statistical structural testing in method level is suitable to detect the logical errors in statements. On the other hand, the statistical functional testing in object level can expose the incorrect implementations which will lead to failure state transitions. Furthermore, a mixed statistical testing framework can be constructed by combining the above two approaches in different levels.Determining inter-class test order is one of the most difficult tasks in cluster level testing. The concept of extended/weighted object relation diagram (EORD/WORD) is presented by extending the traditional object relation diagram (ORD). While generating the inter-class test order based on WORD, minimizing the number of realistic stubs (not the number of classes to be stubbed) is regarded as optimization objective. Some heuristic rules, such as association intensity, cycling weight and direction factor of edge, are treated as important criteria to cut association edges to break cycles. An improved algorithm ICTO is proposed via analyzing some principles of the existing methods and overcoming some of their drawbacks. This algorithm has some merits such as the fewer number recursion times, lower cost of generating class stubs, and excellent stability.Object-Oriented technology provides an essential support for component realization, so component generally retains the basic Object-Oriented characters, and component- based software’s testing can be viewed as the continuation and extension of OO program testing. Due to lack of the detailed internal constructs and change information of the externally-developed components, system testers (i.e., component users) generally can’t perform effective testing (especially regression testing), on their component-based systems. The ultimate reason is that they are unable to select the proper test cases to retest the affected parts caused by the modifications in component. Through analyzing the drawbacks of existing regression testing techniques for component-based systems, two improved strategies are proposed: one is based on the enhanced representation of change information of component version, and the other is implemented via the component built-in test design. Preliminary experiment results show that the above two strategies of regression test case selection are fairly feasible and cost-effective in practice.Software testing is a practical activity combined with theory, technology, tool, and management. Among these four important facets, assistant tool for testing plays an outstanding role in software development in practice, and should not be neglected. In order to facilely perform testing on C or C++ programs, a prototype tool called CppTest is designed and implemented. It can employ three levels’testing, namely (1) structural testing in method level by analyzing program’s constructs, instrumenting probes, redirecting I/O stream, etc., (2) state-based class level testing through modeling state transition behaviors using an extended finite state machine (EFSM) from the class specifications, and (3) system level black-box testing with some traditional strategies such as equivalence partitioning and boundary-value analysis. In addition, the tool can employ clustering analysis on the failure executions and then sample fairly few representative test executions to direct program diagnosis. Multi-levels’testing capability, test project management, high automation, visualization and scalability are the remarkable merits of the prototype system.

  • 【分类号】TP311.11
  • 【被引频次】10
  • 【下载频次】1059
  • 攻读期成果
节点文献中: