Generate High-Coverage Unit Test Data Using the LLM Tool

Unit testing is a critical phase in the software development lifecycle, essential for ensuring the quality and reliability of code. However, the manual creation of unit test scripts and the preparation of corresponding test data can be a time consuming and labor intensive process. To address these challenges, several automated approaches have been explored, including search based, constraint based, random-based, and symbolic execution based techniques for generating unit tests. In recent years, the rapid advancement of large language models (LLMs) has opened new avenues for automating various tasks, including the automatic generation of unit test scripts and test data. Despite their potential, using LLMs in a straightforward manner to generate unit tests may lead to low test coverage. This means that a significant portion of the source code, including specific statements or branches, may remain untested, which can reduce the effectiveness of the tests. To overcome this limitation, the paper presents a novel approach that not only automates the generation of unit test scripts and test data but also improves test coverage. The proposed solution begins by using an LLM tool (such as ChatGPT) to generate initial unit test scripts and data from the source code. To enhance test coverage, the specification document of the source code is also input into the LLM to generate additional test data. Following this, a coverage checking tool is used to evaluate the test coverage and identify untested statements or branches. The LLM is then applied again to generate new test data aimed specifically at addressing these gaps. The initial experimental results indicate that this method significantly improves test coverage, demonstrating its potential to enhance automated unit testing processes.

Authors

Publication Details

Journal
International Journal of Innovative Technology and Exploring Engineering
Published
2024-11-27
DOI
https://doi.org/10.35940/ijitee.l9996.13121124
Citations
1
Primary Topic
Software Testing and Debugging Techniques
Type
article
Field-Weighted Citation Impact
0.49
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Generate High-Coverage Unit Test Data Using the LLM Tool

Chi Quynh Nguyen, Ngoc Thi Bich
1 citations
International Journal of Innovative Technology and Exploring Engineering
Software Testing and Debugging Techniques
0.49
article

Generate High-Coverage Unit Test Data Using the LLM Tool

Chi Quynh Nguyen, Ngoc Thi Bich
article en
1 citations

Abstract

Unit testing is a critical phase in the software development lifecycle, essential for ensuring the quality and reliability of code. However, the manual creation of unit test scripts and the preparation of corresponding test data can be a time consuming and labor intensive process. To address these challenges, several automated approaches have been explored, including search based, constraint based, random-based, and symbolic execution based techniques for generating unit tests. In recent years, the rapid advancement of large language models (LLMs) has opened new avenues for automating various tasks, including the automatic generation of unit test scripts and test data. Despite their potential, using LLMs in a straightforward manner to generate unit tests may lead to low test coverage. This means that a significant portion of the source code, including specific statements or branches, may remain untested, which can reduce the effectiveness of the tests. To overcome this limitation, the paper presents a novel approach that not only automates the generation of unit test scripts and test data but also improves test coverage. The proposed solution begins by using an LLM tool (such as ChatGPT) to generate initial unit test scripts and data from the source code. To enhance test coverage, the specification document of the source code is also input into the LLM to generate additional test data. Following this, a coverage checking tool is used to evaluate the test coverage and identify untested statements or branches. The LLM is then applied again to generate new test data aimed specifically at addressing these gaps. The initial experimental results indicate that this method significantly improves test coverage, demonstrating its potential to enhance automated unit testing processes.

International Journal of Innovative Technology and Exploring EngineeringVol. 13(12)
Decent work and economic growth
Openalex Percentile: Top 29%
Software Testing and Debugging Techniques
0.49
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Generate High-Coverage Unit Test Data Using the LLM Tool — Chi Quynh Nguyen, Ngoc Thi Bich · International Journal of Innovative Technology and Exploring Engineering (2024) | TGRS Research Map | TGRS