[Paper Review] ChatGPT vs SBST: A Comparative Assessment of Unit Test Suite Generation
The paper compares unit test suites generated by ChatGPT and EvoSuite (SBST) across correctness, readability, code coverage, and bug detection, revealing ChatGPT’s strengths in diversity and realism of tests but highlighting compilation and coverage gaps.
Recent advancements in large language models (LLMs) have demonstrated exceptional success in a wide range of general domain tasks, such as question answering and following instructions. Moreover, LLMs have shown potential in various software engineering applications. In this study, we present a systematic comparison of test suites generated by the ChatGPT LLM and the state-of-the-art SBST tool EvoSuite. Our comparison is based on several critical factors, including correctness, readability, code coverage, and bug detection capability. By highlighting the strengths and weaknesses of LLMs (specifically ChatGPT) in generating unit test cases compared to EvoSuite, this work provides valuable insights into the performance of LLMs in solving software engineering problems. Overall, our findings underscore the potential of LLMs in software engineering and pave the way for further research in this area.
Motivation & Objective
- Assess whether ChatGPT can generate correct unit tests for Java methods.
- Evaluate the readability and maintainability of ChatGPT-generated tests.
- Compare code coverage of ChatGPT-generated tests with EvoSuite (SBST).
- Measure the bug-detection capability of ChatGPT-generated tests using static analysis.
Proposed method
- Use EvoSuite as the SBST baseline for Java unit-test generation.
- Prompt ChatGPT with code segments to generate JUnit tests using a standardized prompt.
- Evaluate correctness by compiling/executing tests and analyzing with SpotBugs for bugs.
- Measure readability via code style checks (Checkstyle) and complexity metrics (cyclomatic and cognitive).
- Assess code coverage using JaCoCo instruction/statement coverage and compare averages across subjects.

Experimental results
Research questions
- RQ1RQ1 Correctness: Are ChatGPT’s unit test suite suggestions correct?
- RQ2RQ2 Readability: How understandable is the ChatGPT-generated test suite?
- RQ3RQ3 Code Coverage: How does ChatGPT perform in terms of code coverage compared to SBST?
- RQ4RQ4 Bug Detection: How effective are ChatGPT and SBST in generating bug-detecting tests?
Key findings
- 207 Java classes from 75 projects were analyzed after applying long-input constraints.
- 69.6% of ChatGPT-generated tests compiled and executed without human intervention.
- SpotBugs found 403 potential bugs across 204 test cases (3 originally failed to compile).
- 61.2% of ChatGPT-generated test cases were bug-free; 9.8% had Scariest/Scary priority bugs.
- Evosuite achieved higher average statement coverage (74.2%) than ChatGPT (55.4%), while ChatGPT outperformed EvoSuite in 37 of 207 classes and in 10 of 75 projects.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.