ChatUniTest: a ChatGPT-based automated unit test generation tool

05/08/2023
by   Zhuokui Xie, et al.
0

Unit testing is a crucial, yet often tedious and time-consuming task. To relieve developers from this burden, automated unit test generation techniques are developed. Existing automated unit test generation tools, such as program-analysis-based tools like EvoSuite and Randoop, lack program comprehension, resulting in unit tests with poor readability and limited assertions. Language-model-based tools, such as AthenaTest and A3Test, have limitations in the generation of correct unit tests. In this paper, we introduce ChatUniTest, a ChatGPT-based automated unit test generation tool developed under the Generation-Validation-Repair framework. ChatUniTest generates tests by parsing the project, extracting essential information, and creating an adaptive focal context that includes the focal method and its dependencies within the pre-defined maximum prompt token limit. The context is incorporated into a prompt and subsequently submitted to ChatGPT. Once ChatGPT's response is received, ChatUniTest proceeds to extract the raw test from the response. It then validates the test and employs rule-based repair to fix syntactic and simple compile errors, followed by ChatGPT-based repair to address challenging errors. Our rigorous evaluation demonstrates that ChatUniTest outperforms EvoSuite in branch and line coverage, surpasses AthenaTest and A3Test in focal method coverage, and effectively generates assertions while utilizing mock objects and reflection to achieve test objectives.

READ FULL TEXT

page 3

page 11

research
05/07/2023

No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generation

Unit testing is essential in detecting bugs in functionally-discrete pro...
research
10/12/2021

NetRep: Automatic Repair for Network Programs

Debugging imperative network programs is a challenging task for develope...
research
02/10/2022

Pynguin: Automated Unit Test Generation for Python

Automated unit test generation is a well-known methodology aiming to red...
research
08/15/2023

Automated Test Case Generation Using Code Models and Domain Adaptation

State-of-the-art automated test generation techniques, such as search-ba...
research
02/27/2021

Bounded Exhaustive Search of Alloy Specification Repairs

The rising popularity of declarative languages and the hard to debug nat...
research
06/04/2019

Bridging the Gap between Unit Test Generation and System Test Generation

Common test generators fall into two categories. Generating test inputs ...
research
07/11/2023

Tests4Py: A Benchmark for System Testing

Benchmarks are among the main drivers of progress in software engineerin...

Please sign up or login with your details

Forgot password? Click here to reset