Studying the Impact of Early Test Termination Due to Assertion Failure on Code Coverage and Spectrum-based Fault Localization
Md. Ashraf Uddin, Shaowei Wang, An Ran Chen, Tse-Hsun (Peter) Chen, and Muhammad Asaduzzaman
断言通常用于验证软件测试中的预期程序行为(例如,如果方法的返回值等于预期值)。 虽然在单个测试中仅使用一个断言以避免代码气味(例如,断言轮盘赌)是一种建议的做法,但在一个测试中具有多个断言是常见的。 具有多个断言的测试的一个问题是,当测试在早期断言(不是最后一个)时失败时,测试将在该点终止,并且剩余的测试代码不会执行。 反过来,这可能会降低代码覆盖和依赖代码覆盖信息的技术的性能(例如,基于频谱的故障定位)。 我们把这种情况称为早期测试终止。 了解早期测试终止对测试覆盖范围的影响对于软件测试和调试非常重要,特别是对于依赖于从测试中获得的覆盖信息的技术。 我们通过调查6个开源项目的207个版本,对断言失败(即早期测试终止)进行了第一次早期测试终止的实证研究。 我们发现,由于断言失败,失败的测试(19.1%)中不可忽视的部分被提前终止。 我们的研究结果表明,早期测试终止既损害了代码覆盖率,也损害了基于频谱的故障定位的有效性。 例如,在消除早期测试终止后,55%的研究版本提高了线/分支覆盖率,并且与原始设置(不消除早期测试终止)相比,两种流行的SBFL技术Ochiai和Talantula的性能分别提高了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 th...