一种面向交互代码的构件合约化测试方法

1.陕西职业技术学院 计算机科学系,陕西 西安 710100; 2.西安通信学院 信息服务系,陕西 西安 710106

构件集成测试; 合约检查; 粘贴代码; 插桩

Component testing research based on contract checking
ZHAO Yan-ni1,GUO Hua-lei2

(-07x3+0.000 306 229x2-0.086 63x+1.746 07ept.of Computer Science,Shaanxi Vocational & Technical College,Xi'an 710100,China; 2.Dept.of Information service,Xi'an Communication College,Xi'an 710016,China)

component integration testing; contract checking; paste code; instrumentation

备注

构件技术是软件复用的关键技术,构件测试是检测构件故障保证构件质量的重要手段。构件故障分为构件本身的故障和构件化软件集成时的故障,前者由于构件开发者熟悉源代码而易于测试和定位; 后者由于软件复用者对构件的不清楚和集成的复杂性导致故障往往难以检测和发现,因此构件集成测试中的故障测试是目前研究的难点问题之一。构件集成测试离不开交互代码(粘贴代码),文中提出了一种面向粘贴代码的构件合约化测试方法。分析了基于粘贴代码的构件测试中的四种故障类型; 针对这四种故障类型,依据合约的适应性,阐述了基于XML的粘贴代码合约的构造机理; 并且给出了构件集成中基于合约检查的测试过程; 最后以网络购物系统为应用实例,验证了该方法的有效性和实用性。该方法为捕捉错误,抛出异常信息,快速定位构件集成中的故障位置,准确发现故障原因提供了一种非常有效的途径。该方法的使用减少了构件集成测试中粘贴代码产生的冗余,提高了测试的灵活性,实现了高效的软件复用,缩短了软件开发周期,降低了开发成本。

Component technology is the key technology for software reuse,Component testing is an important means to detect the component fault and ensure the quality of components.Component fault is divided into component fault itself and the fault of component software integration,the former because the component developers familiar with the source code and so easy to test and locate; but the latter because the man who reuse software is not clear the component structure and integration complexity so the fault is often difficult to detect and discover,therefore,the fault testing of component integration is one of the difficult problems in the present study.The component integration testing does not leave interaction code(paste code).In the paper,a component contract testing method is proposed based on the paste code-oriented.The four fault type is analyzed based on the paste code in the component integration; based on these four types of fault,analyze the adaptability of the contract,elaborate the contract construction mechanism based on XML; at last,gives the network shopping system as an application examples,verify the validity and practicability of the proposed method.The method provides a very efficient way to capture the error,throw exceptions,quickly locate the fault location in the component integration and accurately find the fault cause.The use of the method can decrease the redundancy and paste the code in the component integration testing,improve the flexibility of test,realize the reuse efficiency,shorten the software development cycle,reduce the cost of development.