软件测试是保证软件质量的一种重要手段,其中,回归测试又是在软件工程中最耗费时间,且执行频繁的一项活动。为了使新版本中的软件错误能尽早被发现,许多开发团队利用持续集成来改进软件过程,但由于频繁的测试以及测试资源的限制,每次测试只能执行一小部分用例,使许多缺陷无法被及时发现。测试用例优先级技术是近年来软件测试领域的一个研究热点,它根据用例的特点对不同用例赋予不同的优先级,使得检测代码缺陷能力高的用例能更早地执行。本文结合持续集成环境的特点,对现有的测试用例优先级技术进行研究和改进,将测试过程划分为两类,即快速测试和全局测试。在快速测试中,对传统的基于文本比较的代码变更的技术进行了改进,把变更前后的代码转化成抽象语法树,根据变更结点所在语法树的位置以及变更的类型赋予不同的权重。在变更分析的基础上,考虑了用例对变更覆盖的几率,用例的执行时间以及用例发现缺陷的几率等因素,并以此改进了传统上基于覆盖率上的贪心算法的不足。在全局测试中,为了弥补快速测试中基于代码变更优先级技术的不足之处,本文采用了基于用例相似性的技术,针对现有的相似性度量技术在全局测试中存在的缺点,提出新的用例特征选择方法和相似性度量方程,在创建优先级队列时,采用了最小相似性优先的算法,使用例能根据其特征更均衡地被执行。此外,本文结合了企业内部常用的多机测试环境,根据测试机器的负载,创建多个优先级队列。最后,本文描述了如何实现持续集成环境中的用例优先级技术模块,并使该模块与现有的持续集成测试环境相结合。
Software testing is an important way to ensure software quality, and regression testing is the most time consuming and most frequently performed activity in software engineering. In order to detect software defects earlier, more and more development teams use continuous integration to improve the software process, but due to the frequent testing and the limitation of resource, each time only a small portion of test cases can be executed, many potential defects cannot be detected in time.Test case prioritization (TCP) has become a research focus in the area of software testing recently. TCP assigns test cases priorities according to their ability to detect software faults.Test case prioritization technology is a hot topic in recent years in the field of software testing. It is characterized by the use cases for different use cases given different priorities, making the detection of code defects with high capacity use cases can be performed earlier.This paper discusses and summarizes the existing TCP technology taking the characteristics of continuous integration environment into consideration, divides the continuous testing process into two steps: quick testing and global testing. In quick testing, the traditional technology based on “text diff operation” of source files has been improved. We firstly convert the modified and the corresponding source code into abstract syntax trees, and then detect the changes by comparing the two trees, assign each change weight depending on its type and its position on the syntax tree. On the base of change analysis, we take below factors into consideration and then improve the traditional greedy algorithm which solely relies on the coverage: the probability that each test case covers the changes, the probability that each test case detects the defects brought in by the changes, and the execution time of each test case. In global testing, in order to compensate for deficiencies of the TCP based on code change in the quick testing, we adopt a similarity-based technique. We analyze the shortcomings of the existing similarity-based technique in the global test, and propose a novel feature selection method and similarity measure. In order to diversify the test cases as more as possible during execution, we use a minimum similarity priority algorithm. In addition, we also incorporate TCP technique into the multi-machine test environment that is usually used in company, and create multiple priority queues according to the load of each machine. Finally, this thesis describes how to implement TCP module in continuous integration environment.