一句话:提出 PYURIFY,通过原子化与动态切片净化 Python 测试,提升统计故障定位精度。
统计故障定位(SFL)利用测试覆盖来排序可疑程序元素,但当测试包含多个断言或与故障无关的代码时,测试结果与故障代码之间的关联会被掩盖,导致定位精度较低。测试用例净化通过将复杂测试转换为简化的单断言变体来缓解该问题。本文提出 PYURIFY,一个为 Python 实现测试用例净化的工具,包含两个步骤:首先,原子化将含多个断言的测试拆分为多个单断言测试;其次,动态程序切片移除与每个断言无关的代码。该净化过程产生更干净的测试谱,使 SFL 技术能更准确地定位故障代码。PYURIFY 同时提供命令行界面与 Python API,便于与现有测试及故障定位工作流集成。在真实 Python 缺陷上的评估表明,测试用例净化能持续提升故障定位的准确性。
Statistical fault localization (SFL) techniques use test coverage to rank suspicious program elements. However, they often suffer from low precision when tests contain multiple assertions or unrelated code that obscures the relationship between test outcomes and faulty code. Test case purification addresses this problem by transforming complex test cases into simplified, single-assertion variants. We present PYURIFY, a tool that implements test case purification for Python through two steps: first, atomization splits each test with multiple assertions into separate single-assertion tests; second, dynamic program slicing removes code irrelevant to each assertion. This purification process produces cleaner test spectra, enabling SFL techniques to pinpoint faulty code more accurately. PYURIFY provides both a command-line interface and a Python API for seamless integration with existing testing and fault localization workflows. Our evaluation of real Python bugs demonstrates that test case purification consistently improves fault localization accuracy.