The reviewed record of science sign in
Pith

arxiv: 2305.04207 · v3 · pith:FFL425NI · submitted 2023-05-07 · cs.SE

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

Reviewed by Pith T0 review T1 audit T2 compute T3 formal T4 kernel pith:FFL425NIrecord.jsonopen to challenge →

classification cs.SE
keywords testschatgpttestunitgeneratedgenerationchattestercorrectness
0
0 comments X
read the original abstract

Unit testing is essential in detecting bugs in functionally-discrete program units. Manually writing high-quality unit tests is time-consuming and laborious. Although traditional techniques can generate tests with reasonable coverage, they exhibit low readability and cannot be directly adopted by developers. Recent work has shown the large potential of large language models (LLMs) in unit test generation, which can generate more human-like and meaningful test code. ChatGPT, the latest LLM incorporating instruction tuning and reinforcement learning, has performed well in various domains. However, It remains unclear how effective ChatGPT is in unit test generation. In this work, we perform the first empirical study to evaluate ChatGPT's capability of unit test generation. Specifically, we conduct a quantitative analysis and a user study to systematically investigate the quality of its generated tests regarding the correctness, sufficiency, readability, and usability. The tests generated by ChatGPT still suffer from correctness issues, including diverse compilation errors and execution failures. Still, the passing tests generated by ChatGPT resemble manually-written tests by achieving comparable coverage, readability, and even sometimes developers' preference. Our findings indicate that generating unit tests with ChatGPT could be very promising if the correctness of its generated tests could be further improved. Inspired by our findings above, we propose ChatTESTER, a novel ChatGPT-based unit test generation approach, which leverages ChatGPT itself to improve the quality of its generated tests. ChatTESTER incorporates an initial test generator and an iterative test refiner. Our evaluation demonstrates the effectiveness of ChatTESTER by generating 34.3% more compilable tests and 18.7% more tests with correct assertions than the default ChatGPT.

This paper has not been read by Pith yet.

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Forward citations

Cited by 10 Pith papers

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score.

  1. LogicHunter: Testing LLM Agent Frameworks with an Agentic Oracle

    cs.SE 2026-07 conditional novelty 7.0

    LogicHunter combines specification-driven test generation with a ReAct-based agentic oracle to discover 40 previously unknown bugs in LangChain, LlamaIndex, and CrewAI, achieving 91.17% oracle precision.

  2. Uncovering Business Logic Bugs via Semantics-Driven Unit Test Generation

    cs.SE 2026-04 conditional novelty 7.0

    SeGa extracts business semantics from requirements to generate unit tests that detect 22-25 more real-world business logic bugs than prior LLM-based methods in industrial Go projects.

  3. SWE-RL: Advancing LLM Reasoning via Reinforcement Learning on Open Software Evolution

    cs.SE 2025-02 unverdicted novelty 7.0

    SWE-RL uses RL on software evolution data to train LLMs achieving 41% on SWE-bench Verified with generalization to other reasoning tasks.

  4. Humanizing Automatically Generated Unit Test Suites with LLM-Based Refactoring

    cs.SE 2026-06 unverdicted novelty 6.0

    TestHumanizer uses LLMs as controlled refactoring layers on EvoSuite suites to boost readability and maintainability, achieving 88-98% compilation rates and developer preference gains on 350 classes from Defects4J and SF110.

  5. Humanizing Automatically Generated Unit Test Suites with LLM-Based Refactoring

    cs.SE 2026-06 unverdicted novelty 6.0

    TestHumanizer uses LLMs as refactoring layers on EvoSuite suites to reach 88-98% compilation rates and better readability on 350 classes from Defects4J and SF110 while preserving coverage.

  6. Co-Located Tests, Better AI Code: How Test Syntax Structure Affects Foundation Model Code Generation

    cs.SE 2026-04 unverdicted novelty 6.0

    Co-locating tests with implementation code yields substantially higher preservation and correctness in foundation-model-generated programs than separated test syntax.

  7. MR-Adopt: Automatic Deduction of Input Transformation Function for Metamorphic Testing

    cs.SE 2024-08 unverdicted novelty 6.0

    MR-Adopt deduces input transformations from hard-coded MR test cases using LLMs, data-flow refinement, and output-relation selection to enable reuse with new source inputs.

  8. LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code

    cs.SE 2024-03 unverdicted novelty 6.0

    LiveCodeBench collects 400 recent contest problems to create a contamination-free benchmark evaluating LLMs on code generation and related capabilities like self-repair and execution.

  9. PR-Aware Automated Unit Test Generation: Challenges and Opportunities

    cs.SE 2026-05 unverdicted novelty 5.0

    EvoSuite produced at least one fail-to-pass test for 36% of PRs versus 13% for GPT-4o, but both tools generated no meaningful change-capturing tests for 64% of the PRs evaluated.

  10. Enhancing Large Language Models with Retrieval Augmented Generation for Software Testing and Inspection Automation

    cs.SE 2026-04 unverdicted novelty 3.0

    RAG-enhanced LLMs show generally positive effects on automated test generation and code inspection by supplying supplementary context that reduces hallucinations.