一句话:提出 UTGen,用大语言模型改进自动生成单元测试的命名、测试数据与注释,从而提升可理解性。
自动单元测试生成器(如 EvoSuite 等基于搜索的测试工具)虽能生成高覆盖率测试,但生成结果往往难以被软件工程师理解。本文提出 UTGen,将基于搜索的软件测试与大语言模型结合,通过上下文化测试数据、改进标识符命名以及添加描述性注释来增强自动生成测试用例的可理解性。作者开展了一项有 32 名学术界与工业界参与者参加的对照实验,以缺陷修复任务模拟真实开发场景,考察单元测试可理解性对工程师修复缺陷能力的影响。结果显示,使用 UTGen 测试用例的参与者相比基线最多多修复 33% 的缺陷,并最多减少 20% 的耗时;后测问卷也表明,增强后的测试名称、测试数据和变量名改善了参与者的缺陷修复过程。
Automated unit test generators, particularly searchbased software testing tools like EvoSuite, are capable of generating tests with high coverage. Although these generators alleviate the burden of writing unit tests, they often pose challenges for software engineers in terms of understanding the generated tests. To address this, we introduce UTGen, which combines searchbased software testing and large language models to enhance the understandability of automatically generated test cases. We achieve this enhancement through contextualizing test data, improving identifier naming, and adding descriptive comments. Through a controlled experiment with 32 participants from both academia and industry, we investigate how the understandability of unit tests affects a software engineer's ability to perform bug-fixing tasks. We selected bug-fixing to simulate a real-world scenario that emphasizes the importance of understandable test cases. We observe that participants working on assignments with UTGen test cases fix up to 33 % more bugs and use up to 20 % less time when compared to baseline test cases. From the post-test questionnaire, we gathered that participants found that enhanced test names, test data, and variable names improved their bugfixing process.
DOI 原文 ·
@inproceedings{paperbot8806,
title = {Leveraging Large Language Models for Enhancing the Understandability of Generated Unit Tests},
author = {Amirhossein Deljouyi and Roham Koohestani and Maliheh Izadi and Andy Zaidman},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00032}
}