TestART: Improving LLM-based Unit Testing via Co-evolution of Automated Generation and Repair Iteration

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Gu, Siqi, Zhang, Quanjun, Li, Kecheng, Fang, Chunrong, Tian, Fangyuan, Zhu, Liuchuan, Zhou, Jianyi, Chen, Zhenyu
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866909558914416640
author Gu, Siqi
Zhang, Quanjun
Li, Kecheng
Fang, Chunrong
Tian, Fangyuan
Zhu, Liuchuan
Zhou, Jianyi
Chen, Zhenyu
author_facet Gu, Siqi
Zhang, Quanjun
Li, Kecheng
Fang, Chunrong
Tian, Fangyuan
Zhu, Liuchuan
Zhou, Jianyi
Chen, Zhenyu
contents Unit testing is crucial for detecting bugs in individual program units but consumes time and effort. Recently, large language models (LLMs) have demonstrated remarkable capabilities in generating unit test cases. However, several problems limit their ability to generate high-quality unit test cases: (1) compilation and runtime errors caused by the hallucination of LLMs; (2) lack of testing and coverage feedback information restricting the increase of code coverage;(3) the repetitive suppression problem causing invalid LLM-based repair and generation attempts. To address these limitations, we propose TestART, a novel unit test generation method. TestART improves LLM-based unit testing via co-evolution of automated generation and repair iteration, representing a significant advancement in automated unit test generation. TestART leverages the template-based repair strategy to effectively fix bugs in LLM-generated test cases for the first time. Meanwhile, TestART extracts coverage information from successful test cases and uses it as coverage-guided testing feedback. It also incorporates positive prompt injection to prevent repetition suppression, thereby enhancing the sufficiency of the final test case. This synergy between generation and repair elevates the correctness and sufficiency of the produced test cases significantly beyond previous methods. In comparative experiments, TestART demonstrates an 18% improvement in pass rate and a 20% enhancement in coverage across three types of datasets compared to baseline models. Additionally, it achieves better coverage rates than EvoSuite with only half the number of test cases. These results demonstrate TestART's superior ability to produce high-quality unit test cases by harnessing the power of LLMs while overcoming their inherent flaws.
format Preprint
id arxiv_https___arxiv_org_abs_2408_03095
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle TestART: Improving LLM-based Unit Testing via Co-evolution of Automated Generation and Repair Iteration
Gu, Siqi
Zhang, Quanjun
Li, Kecheng
Fang, Chunrong
Tian, Fangyuan
Zhu, Liuchuan
Zhou, Jianyi
Chen, Zhenyu
Software Engineering
Unit testing is crucial for detecting bugs in individual program units but consumes time and effort. Recently, large language models (LLMs) have demonstrated remarkable capabilities in generating unit test cases. However, several problems limit their ability to generate high-quality unit test cases: (1) compilation and runtime errors caused by the hallucination of LLMs; (2) lack of testing and coverage feedback information restricting the increase of code coverage;(3) the repetitive suppression problem causing invalid LLM-based repair and generation attempts. To address these limitations, we propose TestART, a novel unit test generation method. TestART improves LLM-based unit testing via co-evolution of automated generation and repair iteration, representing a significant advancement in automated unit test generation. TestART leverages the template-based repair strategy to effectively fix bugs in LLM-generated test cases for the first time. Meanwhile, TestART extracts coverage information from successful test cases and uses it as coverage-guided testing feedback. It also incorporates positive prompt injection to prevent repetition suppression, thereby enhancing the sufficiency of the final test case. This synergy between generation and repair elevates the correctness and sufficiency of the produced test cases significantly beyond previous methods. In comparative experiments, TestART demonstrates an 18% improvement in pass rate and a 20% enhancement in coverage across three types of datasets compared to baseline models. Additionally, it achieves better coverage rates than EvoSuite with only half the number of test cases. These results demonstrate TestART's superior ability to produce high-quality unit test cases by harnessing the power of LLMs while overcoming their inherent flaws.
title TestART: Improving LLM-based Unit Testing via Co-evolution of Automated Generation and Repair Iteration
topic Software Engineering
url https://arxiv.org/abs/2408.03095