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

研究断言失败导致的早期测试终止对代码覆盖率和基于频谱的故障定位的影响

Studying the Impact of Early Test Termination Due to Assertion Failure on Code Coverage and Spectrum-based Fault Localization

University of Manitoba(曼尼托巴大学);University of Alberta(阿尔伯塔大学);Concordia University(康考迪亚大学);University of Windsor(温莎大学)

Md. Ashraf Uddin, Shaowei Wang, An Ran Chen, Tse-Hsun, Chen, Muhammad Asaduzzaman

AI总结:

本文首次实证研究断言失败导致的早期测试终止对代码覆盖率和基于频谱的故障定位的影响,发现19.1%的失败测试因此终止,消除该问题可提升覆盖率及SBFL技术性能。

摘要:

断言在软件测试中常用于验证程序的预期行为(例如,方法的返回值是否等于预期值)。尽管推荐在单个测试中仅使用一个断言以避免代码异味(例如,断言轮盘赌),但单个测试中包含多个断言的情况很常见。含多个断言的测试存在一个问题:当测试在早期断言(非最后一个)失败时,会在该点终止,剩余测试代码无法执行。这可能会降低代码覆盖率,以及依赖代码覆盖信息的技术(如基于频谱的故障定位)的性能。我们将这种场景称为早期测试终止。了解早期测试终止对测试覆盖率的影响对软件测试和调试至关重要,尤其是对依赖测试覆盖信息的技术而言。我们通过研究6个开源项目的207个版本,首次对断言失败导致的早期测试终止进行了实证研究。结果发现,不可忽视的一部分失败测试(19.1%)因断言失败而早期终止。研究表明,早期测试终止会损害代码覆盖率和基于频谱的故障定位的有效性。例如,消除早期测试终止后,55%的研究版本的行/分支覆盖率得到提升,两种流行SBFL技术Ochiai和Tarantula的MFR性能分别提高了15.1%和10.7%(与未消除早期测试终止的原始设置相比)。

英文摘要:

An assertion is commonly used to validate the expected programs behavior (e.g., if the returned value of a method equals an expected value) in software testing. Although it is a recommended practice to use only one assertion in a single test to avoid code smells (e.g., Assertion Roulette), it is common to have multiple assertions in a single test. One issue with tests that have multiple assertions is that when the test fails at an early assertion (not the last one), the test will terminate at that point, and the remaining testing code will not be executed. This, in turn, can potentially reduce the code coverage and the performance of techniques that rely on code coverage information (e.g., spectrum-based fault localization). We refer to such a scenario as early test termination. Understanding the impact of early test termination on test coverage is important for software testing and debugging, particularly for the techniques that rely on coverage information obtained from the testing. We conducted the first empirical study on early test termination due to assertion failure (i.e., early test termination) by investigating 207 versions of 6 open-source projects. We found that a nonnegligible portion of the failed tests (19.1%) is early terminated due to assertion failure. Our findings indicate that early test termination harms both code coverage and the effectiveness of spectrum-based fault localization. For instance, after eliminating early test termination, the line/branch coverage is improved in 55% of the studied versions, and improves the performance of two popular SBFL techniques Ochiai and Tarantula by 15.1% and 10.7% compared to the original setting (without eliminating early test termination) in terms of MFR, respectively.

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

↑