用大模型+突变优先级,让智能合约测试更高效
PRIMG : Efficient LLM-driven Test Generation Using Mutant Prioritization
- 基于突变图训练模型,优先选有潜力的突变体
- 生成测试用例后迭代优化,覆盖率高且规模小
- 适合想提升测试效率的区块链开发者
突变测试是评估和提升软件测试套件有效性的重要方法,但常导致测试用例过多,计算开销大。本文提出PRIMG(突变优先级与精炼集成生成)框架,用于Solidity智能合约的增量式、自适应测试用例生成。该框架包含两个核心模块:突变优先级模块利用在突变包含图上训练的机器学习模型,预测存活突变体的有用性;测试生成模块则使用大语言模型(LLMs)生成并迭代精炼测试用例,确保语法与行为正确性。我们在Code4Arena上的真实Solidity项目上评估了PRIMG的效果。结果表明,PRIMG显著减小了测试套件规模,同时保持高突变覆盖率。优先级模块始终优于随机选择,能以更低计算成本生成高影响力测试。此外,精炼过程有效提升了LLM生成测试的正确性和实用性,解决了其在处理边界情况和复杂逻辑时的固有缺陷。
原文摘要 · Abstract (English)
Mutation testing is a widely recognized technique for assessing and enhancing the effectiveness of software test suites by introducing deliberate code mutations. However, its application often results in overly large test suites, as developers generate numerous tests to kill specific mutants, increasing computational overhead. This paper introduces PRIMG (Prioritization and Refinement Integrated Mutation-driven Generation), a novel framework for incremental and adaptive test case generation for Solidity smart contracts. PRIMG integrates two core components: a mutation prioritization module, which employs a machine learning model trained on mutant subsumption graphs to predict the usefulness of surviving mutants, and a test case generation module, which utilizes Large Language Models (LLMs) to generate and iteratively refine test cases to achieve syntactic and behavioral correctness. We evaluated PRIMG on real-world Solidity projects from Code4Arena to assess its effectiveness in improving mutation scores and generating high-quality test cases. The experimental results demonstrate that PRIMG significantly reduces test suite size while maintaining high mutation coverage. The prioritization module consistently outperformed random mutant selection, enabling the generation of high-impact tests with reduced computational effort. Furthermore, the refining process enhanced the correctness and utility of LLM-generated tests, addressing their inherent limitations in handling edge cases and complex program logic.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。