基于强化学习的分区测试方法
A Reinforcement Learning Based Approach to Partition Testing
-
摘要:研究背景 分区测试是最基础且最常用的软件测试技术之一。该技术首先将待测程序的输入域划分为一组不相交的分区,然后从这些分区创建测试用例。受软件控制论的启发,研究人员提出了一些根据测试过程中获得的反馈信息动态选择分区的策略。目的 已有的分区选择策略的基本思想是,对那些具有较高故障检测潜力的分区分配较高的概率。这些策略主要根据先前的测试结果进行判断与更新。本质上,这种基于反馈的机制可以视作一种学习过程——根据测试执行过程中观察到的结果做出决策。因此,一些先进的学习技术可以用于动态的分区选择,从而进一步提高分区测试的有效性与效率。方法 本文利用强化学习来提高目前最好的自适应分区测试技术。本文所提方法的基本流程为:首先,随机选择一个初始的分区;第二,在当前分区中随机执行一个测试用例,并选择下一个分区;第三,采用某种策略,根据当前测试用例的执行结果和下一个分区的选择结果获得一个即时奖励;第四,更新分区选择策略并移动至下一分区。在测试过程中,反复执行第二至四步直到满足测试停止条件。结果 我们设计了两种算法实现所提技术,即RLAPT_Q和RLAPT_S。通过7个真实程序及其26个错误版本评估所提方法的有效性,实验结果表明,本文方法在故障检测能力和整体测试时间方面优于现有的分区测试技术。结论 本文提出了一种基于强化学习的分区测试方法,设计了两种基于强化学习的分区测试算法:RLAPT_Q和RLAPT_S,采用7个真实程序评估了所提方法的有效性。实验结果验证了强化学习在提高软件测试性能方面的可行性与有效性。未来工作主要在于探讨RLAPT中合适的参数设置,以及探索其他的强化学习算法,进一步提升分区测试的性能。Abstract: Partition testing is one of the most fundamental and popularly used software testing techniques. It first divides the input domain of the program under test into a set of disjoint partitions, and then creates test cases based on these partitions. Motivated by the theory of software cybernetics, some strategies have been proposed to dynamically select partitions based on the feedback information gained during testing. The basic intuition of these strategies is to assign higher probabilities to those partitions with higher fault-detection potentials, which are judged and updated mainly according to the previous test results. Such a feedback-driven mechanism can be considered as a learning process—it makes decisions based on the observations acquired in the test execution. Accordingly, advanced learning techniques could be leveraged to empower the smart partition selection, with the purpose of further improving the effectiveness and efficiency of partition testing. In this paper, we particularly leverage reinforcement learning to enhance the state-of-the-art adaptive partition testing techniques. Two algorithms, namely RLAPT_Q and RLAPT_S, have been developed to implement the proposed approach. Empirical studies have been conducted to evaluate the performance of the proposed approach based on seven object programs with 26 faults. The experimental results show that our approach outperforms the existing partition testing techniques in terms of the fault-detection capability as well as the overall testing time. Our study demonstrates the applicability and effectiveness of reinforcement learning in advancing the performance of software testing.