arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2203.02337cs.SE
收藏

基于搜索的单元测试的基本块覆盖和崩溃再现

Basic Block Coverage for Search-based Unit Testing and Crash Reproduction

Pouria Derakhshanfar, Xavier Devroey, Andy Zaidman

摘要:

基于搜索的技术已被广泛用于白盒测试生成。这些方法中的许多依赖于方法级和分支距离算法来指导搜索过程,并生成具有高的线和分支覆盖率的测试用例。尽管这两种算法取得了积极的结果,但它们只使用与显式分支的覆盖相关的信息(例如,由条件和循环语句指示),但忽略基本代码块中潜在的隐式分支。如果这种隐式分支发生在运行时(例如,如果在无分支方法中抛出异常),则现有的适应度函数不能指导搜索过程。为了解决这个问题,我们引入了一个新的次要目标,称为基本块覆盖(BBC),它考虑到控制流图中的相关基本块的覆盖水平。我们评估了BBC对基于搜索的单元测试生成(使用DynaMOSA算法)和基于搜索的崩溃再现(使用STDistance和WeightedSum适应度函数)的影响。我们的研究结果表明,对于单元测试生成,BBC提高了分支覆盖率的生成测试。虽然很小(约1.5%),但分支覆盖率的这种改进是系统性的,并导致输出域覆盖率和隐式运行时异常覆盖率的增加,以及运行时状态的多样性。在碰撞再现方面,结合STDistance和WeightedSum,BBC有助于为每个适应度函数再现3个新的碰撞。BBC使用STDistance和WeightedSum分别显著减少了再现43.5%和45.1%的碰撞所需的时间。对于这些崩溃,BBC平均减少了71.7%(对于STDistance)和68.7%(对于WeightedSum)的消耗时间。

英文摘要:

Search-based techniques have been widely used for white-box test generation. Many of these approaches rely on the approach level and branch distance heuristics to guide the search process and generate test cases with high line and branch coverage. Despite the positive results achieved by these two heuristics, they only use the information related to the coverage of explicit branches (e.g., indicated by conditional and loop statements), but ignore potential implicit branchings within basic blocks of code. If such implicit branching happens at runtime (e.g., if an exception is thrown in a branchless-method), the existing fitness functions cannot guide the search process. To address this issue, we introduce a new secondary objective, called Basic Block Coverage (BBC), which takes into account the coverage level of relevant basic blocks in the control flow graph. We evaluated the impact of BBC on search-based unit test generation (using the DynaMOSA algorithm) and search-based crash reproduction (using the STDistance and WeightedSum fitness functions). Our results show that for unit test generation, BBC improves the branch coverage of the generated tests. Although small (around 1.5%), this improvement in the branch coverage is systematic and leads to an increase of the output domain coverage and implicit runtime exception coverage, and of the diversity of runtime states. In terms of crash reproduction, in the combination of STDistance and WeightedSum, BBC helps in reproducing 3 new crashes for each fitness function. BBC significantly decreases the time required to reproduce 43.5% and 45.1% of the crashes using STDistance and WeightedSum, respectively. For these crashes, BBC reduces the consumed time by 71.7% (for STDistance) and 68.7% (for WeightedSum) on average.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑