Unit Test Generation using Generative AI : A Comparative Performance Analysis of Autogeneration Tools
Open accessThe DOI matches its Crossref record; 28 of the 28 references it cites were found in a registry or an index.
Abstract
Generating unit tests is a crucial task in software development, demanding substantial time and effort from programmers. The advent of Large Language Models (LLMs) introduces a novel avenue for unit test script generation. This research aims to experimentally investigate the effectiveness of LLMs, specifically exemplified by ChatGPT, for generating unit test scripts for Python programs, and how the generated test cases compare with those generated by an existing unit test generator (Pynguin). For experiments, we consider three types of code units: 1) Procedural scripts, 2) Function-based modular code, and 3) Class-based code. The generated test cases are evaluated based on criteria such as coverage, correctness, and readability. Our results show that ChatGPT's performance is comparable with Pynguin in terms of coverage, though for some cases its performance is superior to Pynguin. We also find that about a third of assertions generated by ChatGPT for some categories were incorrect. Our results also show that there is minimal overlap in missed statements between ChatGPT and Pynguin, thus, suggesting that a combination of both tools may enhance unit test generation performance. Finally, in our experiments, prompt engineering improved ChatGPT's performance, achieving a much higher coverage.*These authors contributed equally.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
In the citing paper
“Research in this area has explored the use of large language models to generate test cases, showing promising results [19, 47, 108, 140, 178, 232].”
From A 2030 Roadmap for Software Engineering (2025) · cites this paper as [19]
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018) · arXiv · doi:10.48550/arxiv.1810.04805 · Cited by 73,173
Language Models are Few-Shot Learners
Brown, T. B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. (2020) · arXiv · doi:10.48550/arxiv.2005.14165 · Cited by 23,372
Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., & Zettlemoyer, L. (2020) · Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics · doi:10.18653/v1/2020.acl-main.703 · Cited by 8,821
Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., & Zettlemoyer, L. (2019) · arXiv · doi:10.48550/arxiv.1910.13461 · Cited by 8,816 · cited 1×
“Unlike other LLMs such as BART[20] and BERT[10], ChatGPT [6] incorporates reinforcement learning from human feedback (RLHF) [7] and a larger model scale, improving generalization and alignment with human intention.”
MethodMcCabe, T. J. (1976) · IEEE Transactions on Software Engineering · doi:10.1109/tse.1976.233837 · Cited by 6,059
T test as a parametric statistic
Kim, T. K. (2015) · Korean Journal of Anesthesiology · doi:10.4097/kjae.2015.68.6.540 · Cited by 1,436
EvoSuite: automatic test suite generation for object-oriented software
Fraser, G., & Arcuri, A. (2011) · Proceedings of the 19th ACM SIGSOFT symposium and the 13th European conference on Foundations of software engineering · doi:10.1145/2025113.2025179 · Cited by 1,110
Feedback-Directed Random Test Generation
Pacheco, C., Lahiri, S. K., Ernst, M. D., & Ball, T. (2007) · 29th International Conference on Software Engineering (ICSE'07) · doi:10.1109/icse.2007.37 · Cited by 863
Randoop: feedback-directed random testing for Java
Pacheco, C., & Ernst, M. D. (2007) · Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companion · doi:10.1145/1297846.1297902 · Cited by 558
An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generation
Schäfer, M., Nadi, S., Eghbali, A., & Tip, F. (2024) · IEEE Transactions on Software Engineering · doi:10.1109/tse.2023.3334955 · Cited by 431 · cited 1×
“These models can also facilitate the generation of unit test cases, streamlining software validation processes[19, 29, 34].”
Background
Research works printed but not linked: 6
- Deep Reinforcement Learning from Human Preferences. Jan Paul F Christiano, Tom Leike, Miljan Brown, Shane Martic, Dario Legg, Amodei, Advances in Neural Information Processing Systems, I. Guyon, U. Von Luxburg. H Bengio, R Wallach, S Fergus, R Vishwanathan, Garnett, 201730
- K Shuvendu, Sarah Lahiri, Aaditya Fakhoury, Georgios Naik, Saikat Sakkas, Madanlal Chakraborty, Piali Musuvathi, Choudhury, arXiv:2208.05950[cs.SE]Curtis von Veh, Jeevana Priya Inala, Chenglong Wang, and Jianfeng Gao. 2023. Interactive Code Generation via Test-Driven User-Intent Formalization. · arXiv
- Paolo Tonella, 10.1145/1013886.1007528Evolutionary Testing of Classes. SIGSOFT Softw. Eng. Notes. 292004. jul 2004 · doi:10.1145/1013886.1007528evolutionary
- ChatUniTest: a ChatGPT-based automated unit test generation tool. Zhuokui Xie, Yinghao Chen, Chen Zhi, Shuiguang Deng, Jianwei Yin, arXiv:2305.04764[cs.SE]2023 · arXiv
- Shengcheng Yu, Chunrong Fang, Yuchen Ling, Chentian Wu, Zhenyu Chen, arXiv:2309.13574[cs.SE]LLM for Test Script Generation and Migration: Challenges, Capabilities, and Opportunities. 2023 · arXiv
- Zhiqiang Yuan, Yiling Lou, Mingwei Liu, Shiji Ding, Kaixin Wang, Yixuan Chen, Xin Peng, arXiv:2305.04207[cs.SE]No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generation. 2023 · arXiv
Cited by
Software Testing With Large Language Models: Survey, Landscape, and Vision
Wang, J., Huang, Y., Chen, C., Liu, Z., Wang, S., & Wang, Q. (2024) · IEEE Transactions on Software Engineering · doi:10.1109/tse.2024.3368208 · Cited by 573
“Similarly, Bhatia [42] experimentally investigates the quality of unit tests generated by LLM compared to a commonly-used test generator Pynguin.”
Generative AI for self-adaptive systems: State of the art and research roadmap
Li, J., Zhang, M., Li, N., Weyns, D., Jin, Z., & Tei, K. (2024) · ACM Transactions on Autonomous and Adaptive Systems · doi:10.1145/3686803 · Cited by 77
Test Intention Guided LLM-Based Unit Test Generation
Nan, Z., Guo, Z., Liu, K., & Xia, X. (2025) · ACM/IEEE International Conference on Software Engineering: Companion Proceedings (ICSE-Companion) · doi:10.1109/icse55347.2025.00243 · Cited by 74
Test Oracle Automation in the Era of LLMs
Molina, F., Gorla, A., & d’Amorim, M. (2025) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3715107 · Cited by 73
A Review of Large Language Models for Automated Test Case Generation
Celik, A., & Mahmoud, Q. H. (2025) · Machine Learning and Knowledge Extraction · doi:10.3390/make7030097 · Cited by 73
Metadata
- Authors
- Bhatia, S., Gandhi, T., Kumar, D., & Jalote, P.
- Affiliations
- Indraprastha Institute of Information Technology Delhi (IN)
- Venue
- Proceedings of the 1st International Workshop on Large Language Models for Code
- Publisher
- ACM
- Published
- 2024-04-20
- Pages
- 54-61
- OpenAlex
- W4402410897
- Cited by
- 55
- References
- 24
- Citations by year
- 2026: 19 · 2025: 30 · 2024: 6
- FWCI
- 14.96
- Type
- conference paper
- Language
- en
- Open access
- green
- arxiv.org
- Locations
- International Workshop on Large Language Models for Code (LLM4Code) (publishedVersion)
- arXiv (Cornell University) (submittedVersion)
- arXiv (Cornell University)
- Topics
- Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Information Systems › Software Engineering Techniques and Practices
- Keywords
- unit test generation, generative AI, large language models, ChatGPT, Python, test coverage, prompt engineering, procedural codes
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.