ChatUniTest: a ChatGPT-based automated unit test generation tool

Authors: Zhuokui Xie, Yinghao Chen, Chen Zhi, Shuiguang Deng, Jianwei Yin

License: CC BY 4.0
AI-generated keywords: Unit testing ChatUniTest EvoSuite AthenaTest A3Test

AI-generated Key Points

  • Unit testing is essential but can be tedious and time-consuming for developers.
  • Existing automated unit test generation tools like EvoSuite and Randoop lack program comprehension, resulting in tests with poor readability and limited assertions.
  • Language-model-based tools like AthenaTest and A3Test also have limitations in generating correct unit tests.
  • The authors introduce ChatUniTest, a ChatGPT-based automated unit test generation tool developed under the Generation-Validation-Repair framework.
  • ChatUniTest works by parsing the project to extract crucial information and creating an adaptive focal context that includes the focal method and its dependencies within a predefined maximum prompt token limit.
  • This context is incorporated into a prompt submitted to ChatGPT for generating a response that is used to extract the raw test.
  • ChatUniTest validates generated tests and employs rule-based repair techniques for fixing syntactic and simple compile errors, while using ChatGPT-based repair for more challenging errors.
  • An evaluation conducted by the authors demonstrates that ChatUniTest surpasses EvoSuite in terms of branch and line coverage.
  • It also outperforms AthenaTest and A3Test in focal method coverage while effectively generating assertions using mock objects and reflection to achieve test objectives.
Also access our AI generated: Comprehensive summary, Lay summary, Blog-like article; or ask questions about this paper to our AI assistant.

Abstract: 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.

Submitted to arXiv on 08 May. 2023

Tools for this paper

Explain it differently 3 free rewrites left today
Export BibTeX · RIS (Zotero, Mendeley, EndNote) · Markdown (Notion, Obsidian) · Premium
Citation alerts Premium
Journal club Slides to present it Premium
For journalists Press kit and hype check Premium

Ask questions about this paper to our AI assistant

You can also chat with multiple papers at once here.

AI assistant instructions?

Results of the summarizing process for the arXiv paper: 2305.04764v1

  • Comprehensive Summary
  • Key points
  • Layman's Summary
  • Blog article
Unit testing is an essential task for developers that can be tedious and time-consuming. To address this issue, automated unit test generation tools have been developed such as EvoSuite and Randoop. However, these existing tools lack program comprehension resulting in tests with poor readability and limited assertions. Language-model-based tools like AthenaTest and A3Test also have limitations in generating correct unit tests. In this paper, the authors introduce ChatUniTest - a ChatGPT-based automated unit test generation tool developed under the Generation-Validation-Repair framework. It works by parsing the project to extract crucial information and creating an adaptive focal context that includes the focal method and its dependencies within a predefined maximum prompt token limit. This context is incorporated into a prompt which is submitted to ChatGPT for generating a response that is used to extract the raw test. To ensure quality of generated tests, ChatUniTest validates them and employs rule-based repair techniques to fix syntactic and simple compile errors while using ChatGPT-based repair for more challenging errors. The authors conducted an evaluation demonstrating superiority of ChatUniTest over EvoSuite in terms of branch and line coverage as well as surpassing AthenaTest and A3Test in focal method coverage while effectively generating assertions using mock objects and reflection to achieve test objectives.

Assess the quality of the AI-generated content by voting

Score: 0

Why do we need votes?

Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.

The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.

Similar papers summarized with our AI tools

Navigate through even more similar papers through a

tree representation

Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.