Teralizer:从传统单元测试到基于属性的测试的语义基于测试泛化
Teralizer: Semantics-Based Test Generalization from Conventional Unit Tests to Property-Based Tests
AI总结:
Teralizer通过单路径符号分析自动将传统单元测试转换为基于属性的测试,提升测试泛化效果并揭示应用障碍。
摘要:
传统单元测试验证单一的输入输出对,导致执行路径上的大多数输入未被测试。基于属性的测试通过生成多个满足属性的输入来解决这一缺陷,但需要大量手动工作来定义属性及其约束。我们提出了一种基于语义的方法,通过单路径符号分析从实现中提取规范,自动将单元测试转换为基于属性的测试。我们通过Teralizer原型进行了演示,这是一个用于Java的工具,可将JUnit测试转换为基于属性的jqwik测试。与以往基于输入输出示例的泛化方法不同,Teralizer从程序语义中推导规范。我们评估了Teralizer在三个逐渐具有挑战性的数据集上的表现。在EvoSuite生成的EqBench和Apache Commons实用程序测试中,Teralizer将突变得分提高了1-4个百分点。对Apache Commons实用程序中成熟的开发人员编写测试的泛化显示仅提高了0.05-0.07个百分点。对632个现实世界的Java项目进行分析,突显了应用障碍:只有1.7%的项目完成了泛化流程,失败主要由于符号分析中的类型支持限制以及我们原型中的静态分析限制。基于结果,我们提供了一条未来工作的路线图,识别需要解决的研究和工程挑战,以推动测试泛化的领域发展。
英文摘要:
Conventional unit tests validate single input-output pairs, leaving most inputs of an execution path untested. Property-based testing addresses this shortcoming by generating multiple inputs satisfying properties but requires significant manual effort to define properties and their constraints. We propose a semantics-based approach that automatically transforms unit tests into property-based tests by extracting specifications from implementations via single-path symbolic analysis. We demonstrate this approach through Teralizer, a prototype for Java that transforms JUnit tests into property-based jqwik tests. Unlike prior work that generalizes from input-output examples, Teralizer derives specifications from program semantics. We evaluated Teralizer on three progressively challenging datasets. On EvoSuite-generated tests for EqBench and Apache Commons utilities, Teralizer improved mutation scores by 1-4 percentage points. Generalization of mature developer-written tests from Apache Commons utilities showed only 0.05-0.07 percentage points improvement. Analysis of 632 real-world Java projects from RepoReapers highlights applicability barriers: only 1.7% of projects completed the generalization pipeline, with failures primarily due to type support limitations in symbolic analysis and static analysis limitations in our prototype. Based on the results, we provide a roadmap for future work, identifying research and engineering challenges that need to be tackled to advance the field of test generalization. Artifacts available at: https://doi.org/10.5281/zenodo.17950381
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。