Bibliographic Details
| Title: |
基于大语言模型的 C 程序单元测试方法. |
| Alternate Title: |
Unit Test Generation for C Programs via Large Language Models. |
| Authors: |
李博诺1, 王 博1 wangbo_cs@bjtu.edu.cn, 陈明达1, 林友芳1, 江云松2, 陈 睿2,3, 李鹏宇2,3 |
| Source: |
Aerospace Control & Application. Feb2025, Vol. 51 Issue 1, p115-122. 8p. |
| Subject Terms: |
*LANGUAGE models, *SOFTWARE reliability, *COMPUTER software development, *COMPUTER software quality control, *LANGUAGE ability testing |
| Abstract (English): |
Unit testing is used to verify the functionality of individual software modules, making it a crucial step in the software development process. It helps in identifying defects in the code in a timely manner, thereby improving the quality and reliability of the software. Manually writing unit tests is time-consuming and labor-intensive, often missing important code logic. To address this, researchers have proposed techniques for automatic generation of unit tests. Recently, pre-trained large language models ( LLM) have been widely applied to tasks related to code generation, and there has been work on generating unit tests for languages such as Java and JavaScript. However, in safety-critical domains such as aerospace, C language programs are predominantly used. To fill this gap, we designed and implemented an LLM-based multi-agent interaction method for generating unit tests for C programs, named LLM4CUTCG. To verify the effectiveness of this method, we constructed 125 target programs without data leakage risks and generated tests for these programs. Experimental results show that the line coverage of the tests generated by LLM4CUTCG is 91. 71%, and the assertion correctness rate is 50. 05% . The coverage rate outperforms traditional methods such as symbolic execution and fuzz testing. [ABSTRACT FROM AUTHOR] |
| Abstract (Chinese): |
单元测试用于检验软件单一模块的功能是否正确, 是软件开发过程中的重要步骤, 可以及时发现代 码中的缺陷, 提升软件的质量和可信度. 由于手动编写单元测试费时费力, 经常遗漏覆盖重要的代码逻辑. 为此, 研究者提出单元测试用例自动生成技术. 近来, 预训练大语言模型 (large language models, LLM) 已经 广泛应用于代码生成相关任务. 然而, 当前在重要的系统级编程语言 C 上, 还没有相关工作. 为了填补这 一空白, 本文面向 C 程序设计并实现了基于 LLM 的单元测试用例生成方法 LLM4CUTCG. 该方法结合 LLM 多智能体交互和程序分析技术, 客服了 LLM 内在问题. 为了验证方法效果, 收集了 125 个 C 语言目标程序, 并针对这些程序生成测试用例. 实验结果表明, LLM4CUTCG 生成的测试行覆盖率为 91. 71%, 测试预言正 确率为 50. 05% . 其覆盖率优于传统方法符号执行. [ABSTRACT FROM AUTHOR] |
| Database: |
Academic Search Index |