An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generation
Open accessThe DOI matches its Crossref record; 78 of the 80 references it cites were found in a registry or an index.
Abstract
Unit tests play a key role in ensuring the correctness of software. However, manually creating unit tests is a laborious task, motivating the need for automation. Large Language Models (LLMs) have recently been applied to various aspects of software development, including their suggested use for automated generation of unit tests, but while requiring additional training or few-shot learning on examples of existing tests. This paper presents a large-scale empirical evaluation on the effectiveness of LLMs for automated unit test generation without requiring additional training or manual effort. Concretely, we consider an approach where the LLM is provided with prompts that include the signature and implementation of a function under test, along with usage examples extracted from documentation. Furthermore, if a generated test fails, our approach attempts to generate a new test that fixes the problem by re-prompting the model with the failing test and error message. We implement our approach inTestPilot, an adaptive LLM-based test generation tool for JavaScript that automatically generates unit tests for the methods in a given project's API. We evaluateTestPilotusing OpenAI'sgpt3.5-turboLLM on 25 npm packages with a total of 1,684 API functions. The generated tests achieve a median statement coverage of 70.2% and branch coverage of 52.8%. In contrast, the state-of-the feedback-directed JavaScript test generation technique, Nessie, achieves only 51.3% statement coverage and 25.6% branch coverage. Furthermore, experiments with excluding parts of the information included in the prompts show that all components contribute towards the generation of effective test suites. We also find that 92.8% ofTestPilot's generated tests have$\leq$50% similarity with existing tests (as measured by normalized edit distance), with none of them being exact copies. Finally, we runTestPilotwith two additional LLMs, OpenAI's oldercode-cushman-002LLM andStarCoder, an LLM for which the training process is publicly documented. Overall, we observed similar results with the former (68.2% median statement coverage), and somewhat worse results with the latter (54.0% median statement coverage), suggesting that the effectiveness of the approach is influenced by the size and training set of the LLM, but does not fundamentally depend on the specific model.
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 [178]
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 · cited 1×
“Some LLMs such as BERT [30] or GPT-3 [31] are trained purely on text extracted from books and other public sources, while others like OpenAI Codex [32] and AlphaCode [33] are put through additional training on publicly available source code to make them better suited for software development tasks…”
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019) · Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers) · doi:10.18653/v1/n19-1423 · Cited by 54,325 · cited 1×
“Some LLMs such as BERT [30] or GPT-3 [31] are trained purely on text extracted from books and other public sources, while others like OpenAI Codex [32] and AlphaCode [33] are put through additional training on publicly available source code to make them better suited for software development tasks…”
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 · cited 1×
“Some LLMs such as BERT [30] or GPT-3 [31] are trained purely on text extracted from books and other public sources, while others like OpenAI Codex [32] and AlphaCode [33] are put through additional training on publicly available source code to make them better suited for software development tasks…”
BackgroundKaugeranna, R., Kaugeranna, E., & Aion, (. S. 4. 6. (2023) · DROPS (Schloss Dagstuhl – Leibniz Center for Informatics) · doi:10.4230/lipics.giscience.2023.43 · Cited by 13,690
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 2×
“Similarly, Tufano et al.’s A THENA T EST [26] generates tests using a BART transformer model [44] fine-tuned on a training set of functions and their corresponding tests.”
Extreme Programming Explained: Embrace Change
Beck, K. L., & Andres, C. (2000) · Cited by 5,902
CUTE: a concolic unit testing engine for C
Sen, K., Marinov, D., & Agha, G. (2005) · Proceedings of the 10th European software engineering conference held jointly with 13th ACM SIGSOFT international symposium on Foundations of software engineering · doi:10.1145/1081706.1081750 · Cited by 1,651 · cited 2×
“This fact has inspired extensive research on techniques for automated test generation including fuzzing [5], [6], feedback-directed random test generation [7], [8], [9], [10], [11], dynamic symbolic execution [12], [13], [14], [15], and search-based and evolutionary techniques [16], [17].”
BackgroundMethodDART: directed automated random testing
Godefroid, P., Klarlund, N., & Sen, K. (2005) · Proceedings of the 2005 ACM SIGPLAN conference on Programming language design and implementation · doi:10.1145/1065010.1065036 · Cited by 1,570 · cited 2×
“This fact has inspired extensive research on techniques for automated test generation including fuzzing [5], [6], feedback-directed random test generation [7], [8], [9], [10], [11], dynamic symbolic execution [12], [13], [14], [15], and search-based and evolutionary techniques [16], [17].”
BackgroundMethodDominance statistics: Ordinal analyses to answer ordinal questions.
Cliff, N. (1993) · Psychological Bulletin · doi:10.1037//0033-2909.114.3.494 · Cited by 1,485 · cited 2×
“Both these differences are statistically significant (p-values 0.002 and 0.027 respectively) with a large effect size, measured by Cliff’s delta [55], of 0.493 for statement coverage and a medium one (0.431) for branch coverage.”
BackgroundMethodInfluential
Research works printed but not linked: 5
- [2] J. Shore and S. Warden, The Art of Agile Development , 2nd ed. O'Reilly, 2021. -
- [3] S. Siddiqui, Learning Test-Driven Development . O'Reilly, 2021. -
- [41] M. Allamanis, H. Jackson-Flux, and M. Brockschmidt, 'Selfsupervised bug detection and repair,' in Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual , M. Ranzato, A. Beygelzimer, Y. N. Dauphin, P. Liang, and J. W. Vaughan, Eds., 2021, pp. 27 865-27 876. [Online]. Available: https://proceedings.neurips.cc/paper/2021/ hash/ea96efc03b9a050d895110db8c4af057-Abstract.html -
- [56] M. Selakovic, M. Pradel, R. Karim, and F. Tip, 'Test generation for higher-order functions in dynamic languages,' Proceedings of the ACM on Programming Languages , vol. 2, no. OOPSLA, pp. 1-27, 2018. - · DOI
- [79] S. Mirshokraie and A. Mesbah, 'JSART: JavaScript assertionbased regression testing,' in Web Engineering - 12th International Conference, ICWE 2012, Berlin, Germany, July 23-27, 2012. Proceedings , ser. Lecture Notes in Computer Science, M. Brambilla, T. Tokuda, and R. Tolksdorf, Eds., vol. 7387. Springer, 2012, pp. 238-252. [Online]. Available: https://doi.org/10.1007/ 978-3-642-31753-8 18 - · doi:10.1007/978-3-642-31753-8
Cited by
Items 401–437 of 437
Lian, X., Wang, J., Zhu, X., Dang, S., & Xu, T. (2026) · Briefings in Bioinformatics · doi:10.1093/bib/bbag452
Bug Whisperer: Unleashing LLMs to Craft Context-Aware Tests Guided by Path Constraints and Bug Clues
Xia, X., Zhang, J., Hu, X., & Li, S. (2026) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3846194
A Hybrid AI Framework for Automated Test Generation and Fault Prediction in Software Engineering
Van, C., & Tuan, N. M. (2026) · Lecture notes in networks and systems · doi:10.1007/978-3-032-23396-7_21
MockWeaver: Mock-Aware Multi-Agent Unit Test Generation for External DependenciesPreprint
Dai, L., Zhang, T., Wang, Q., Liu, X., Jing, Y., Duan, H., & Shi, H. (2026) · SSRN Electronic Journal · doi:10.2139/ssrn.7506899
Building a cross-platform WebXR heritage application from a drone survey using a language modelPreprint
Islam, R., & Almutery, S. (2026) · Research Square · doi:10.21203/rs.3.rs-11062255/v1
From Greedy Steps to Global Optimization: Learning Sequential Test Suite Generation
Wang, G., Yang, C., Zhou, X., Sun, Z., Wang, B., Lo, D., & Hao, D. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832162 · Cited by 5
Chen, J., Wang, Z., Yang, L., Yang, C., Chu, X., Zhou, J., Liang, G., Wang, Q., & Wang, D. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832242 · Cited by 1
“Large-scale evaluations [52] have shown that a significant portion of LLM-generated unit tests fail to compile, regardless of the prompting strategy used [38, 43].”
RICE: Harnessing LLMs and Historical Issues to Discover Internal Rust Compiler Errors
Lu, L., You, W., Liang, B., & Huang, J. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832277
Towards More Realistic Assertion Generation under Mixed-Assertion Scenario
Li, H., Kunpeng, E., Sun, W., Zhang, Q., & Yan, M. L. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832214
“In software engineering (SE), they have been applied to code generation [24, 29, 36, 51], code search [45, 48], code summarization [37, 58], vulnerability detection [18, 49], test generation [12, 33, 46].”
ConUT: Condition-Aware Test Generation for Complex Java Code
Yu, R., Dong, R., Xiao, X., Zhu, X., Wang, S., Wen, S., & Li, Q. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832260
“Most recently, the field has seen a paradigm shift toward leveraging large language models (LLMs), as exemplified by tools such as ChatUniTest [10], TestPilot [32], and SymPrompt [30].”
LLMutantKiller: Using Large Language Models to Generate Tests That Kill Mutants
Khalili, F., Domondon, A., Garg, H., & Tip, F. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832098
“Schäfer et al. [49] present an approach in which an LLM is queried with prompts that provide various details of a function under test (signature, example snippets, documentation, source code) and implement it in a tool called TestPilot .”
InfluentialSelf-citationEnhancing LLM-Based Bug Reproduction via Code Entity Retrieval and Test Case Repair
Ding, H., Jiang, Y., Zhang, Y., & Liu, H. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3832247
CoCoMUT: A Tool for Code-Context Mining and Automated Dataset Generation
Botta, A., Garisa, S., Akurathi, J. V., Sabit, A. A., Woodlief, T., & Hossain, S. B. (2026) · ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity (SPLASH) · doi:10.1145/3837729.3840485
Seniv, M., & Іншин, В. В. (2026) · Науковий вісник НЛТУ України · doi:10.36930/40360404
Pasupuleti, V., Allala, S. R., Tyagi, S., Songa, S. T., & Gulkotwar, N. (2026) · IEEE World Conference on Applied Intelligence and Computing (AIC) · doi:10.1109/aic70896.2026.11716880
“Test-Pilot [8] generates and adaptively re-prompts JavaScript unit tests from API documentation; CoverUp [9] iteratively drives an LLM with per-iteration coverage feedback; Wang et al. [10] survey the rapidly growing LLM-testing landscape.”
Autonomous Quality Assurance of Enterprise Platforms and Products Using Agentic AI
Marconi, N., Chandaka, K., Mohanty, K., Jha, S., Sivalenka, R. R., & Gupta, M. (2026) · International Conference on Emerging Techniques in Computational Intelligence (ICETCI) · doi:10.1109/icetci71772.2026.11710532
“Schafer et al. [5] demonstrated that GPT-4 can generate unit tests competitive with EvoSuite on coverage metrics for open-source Java projects.”
Can LLMs Turn Design Discussions Into Architectural Tests? An Exploratory Study with Codestral
Lucena, A., Alves, E. L. G., & Brunet, J. (2026) · Lecture notes in computer science · doi:10.1007/978-3-032-39236-7_15
LLMCloc: Compiler bug localization via large language model-based root cause analysis
Shi, B., Lu, W., Tang, J., Huang, Z., & Li, W. (2026) · Information and Software Technology · doi:10.1016/j.infsof.2026.108352
Correct According to Whom? Auditing What LLM-Generated Tests Actually Check
Bornais, S. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3844564
Whose Specification Did You Test? The Hidden Interpretation Bias in LLM-Generated Test Suites
Islam, M. M. (2026) · doi:10.1145/3820756.3844908
“Prior empirical studies of LLM testing universally evaluate generated tests against human-written code [2–4].”
FAiLGen: Calibrating LLM for Failing Test Generation with Monte Carlo Tree Search
Li, T. O., Yan, X., DeHui, Y., Jiang, Y., Li, K., Xu, C., Wang, Y., & Cheung, S.-C. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3837478
“Inthispaper, we draw inspiration from existing findings that LLMs can infer expected outputs from program inputs and requirements, as demonstrated by prior LLM-based test generation approaches [15, 50, 63, 65, 68].”
Moon, S., Lee, M.-H., Kim, J., Jhi, Y., Cho, J., & Oh, H. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3834525
“Second, LLM-centric generators [4, 9, 36, 41, 49, 50, 59, 61] that directly prompt an LLM to synthesize tests from the target program can produce readable tests, but fail on both efficiency and reliability.”
Predicate-Guided Synthesis of Input Generators via Gentoo
Vikram, V., & Padhye, R. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3837441 · Cited by 3
“There has recently been a large body of work to use large language models for software testing tasks [24, 53, 58].”
PropGen: Automated Property Generation for Property-Based Testing of Mobile Apps
Xiong, Y., Song, S., Ma, B., Su, T., & Xie, X. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3837536
Nayim, M. A. M., Kouchi, F. R., Sikder, A. K., & Cohen, M. B. (2026) · IEEE/ACM International Workshop on Automated Program Repair (APR) · doi:10.1145/3843776.3844668
Verifier-in-the-Loop LLM Solving of Heap Constraints for Concolic Execution
Xia, S., Cheng, L., Dong, C., She, D., Wang, B., Peng, X., & Dong, Z. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3834410
“…queries an LLM when search-based generation stalls [27]; TestPilot and ChatUniTest generate unit tests end-to-end from signatures and context [13, 45]; MuTAP augments prompts with surviving mutants [17]; CoverUp and HITS refine tests via coverage feed-back or method slicing [1, 56];…”
Large Language Model Enabled Symbolic Execution for Automated Functional Analysis
Liu, M., Chen, Z., Wang, X., He, Z., Gu, J., Chen, M., Wang, L., & Dong, W. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3837524
“Others address challenges: SlicePromptTest4J [64] improves coverage via decomposition; CodaMosa [36] overcomes stagnation in search-based testing; UniTSyn [19] enhances accuracy with static analysis; and TestPilot [57] auto-generates JavaScript unit tests.”
Durelli, V. H. S., Durelli, R. S., & Endo, A. T. (2026) · Journal of Software Engineering Research and Development · doi:10.5753/jserd.2026.7689
“Specifically, given the widespread use of LLMs in various coding-related tasks, it is reasonable to expect that they would be effective in software testing activities, particularly in the generation of unit tests (Schäfer et al., 2024; Abdullin et al., 2025).”
Moraes, D. R. D. S., & Rocha, T. A. B. (2026) · Simpósio Brasileiro de Testes de Software Sistemático e Automatizado (SAST) · doi:10.5753/sast.2026.31499
“Apesar disso, demandam tempo e esforço dos desenvolvedores [15, 24, 28], que em meio a prazos apertados, acabam por negligenciá-los, de maneira que nem sempre as suítes de testes evoluem em consonância com o código, tornando-se defasadas ou alcançando níveis de cobertura insatisfatórios.”
Li, Z. (2026) · SSRN Electronic Journal · doi:10.2139/ssrn.7592567
Framework for Safety Analysis of LLM-Generated Code in Multi-Agent Systems
Avagian, D. A., & Ayrapetyants, K. A. (2026) · Automatic Documentation and Mathematical Linguistics · doi:10.3103/s000510552670072x
Threat Modeling and Property Generation in SoC Security
Hasan, M. A., Ibnat, Z., Tarek, S., Ahmed, B., Ayalasomayajula, A., Das, U., Tehranipoor, M., & Farahmandi, F. (2026) · Springer eBooks · doi:10.1007/978-3-032-34116-7_6
Hanifah, A. M. Z., & Munthe, E. S. (2026) · Digitus Journal of Computer Science Applications · doi:10.61978/digitus.v4i2.2024
“TestPilot demonstrates adaptive use of execution feedback in JavaScript, but its evaluation setting and language differ from the present condition labels (Schäfer et al., 2024).”
Shi, Y., & Song, R. (2026) · Frontiers in Artificial Intelligence · doi:10.3389/frai.2026.1960601
“Schäfer et al. (2024) empirically evaluated LLMs for automated unit-test generation, and Yuan et al. (2024) evaluated and improved ChatGPT for unit-test generation.”
High-Coverage LLM-based Unit Test Code Generation through Control Flow Graph Guidance
Luo, X., Liu, C., Zhao, M., Wu, Z., Lu, T., & Chen, J. (2026) · International Joint Conference on Neural Networks (IJCNN) · doi:10.1109/ijcnn69854.2026.11729616
“Recent research has explored the potential of LLMs in code generation [12], [13], including unit test code generation [14].”
LLM-driven test and test-repair automation for legacy Perl systems: an empirical study at IBM
Leunig, S., & Petersen, K. (2026) · Software Quality Journal · doi:10.1007/s11219-026-09790-3 · Cited by 2
“Systems such as the previously mentioned TESTPILOT (Schäfer et al., 2024 ), ChatTester (Yuan et al., 2024 ), and ChatUniTest (Chen et al., 2024) use a repair loop where errors from compilation or execution are analyzed and fed back to the LLM to generate a corrected version.”
InfluentialAromaLIA: A Language-Independent Approach to Detect Test Smells
Silva, P., Bezerra, C. I. M., & Machado, I. (2026) · doi:10.5753/cbsoft_estendido.2026.29714
Metadata
- Authors
- Schäfer, M., Nadi, S., Eghbali, A., & Tip, F.
- Affiliations
- GitHub, Kidlington, U.K.
- University of Alberta (CA)
- University of Stuttgart (DE)
- Northeastern University (US)
- Venue
- IEEE Transactions on Software Engineering
- Published
- 2024-01
- Volume
- 50
- Issue
- 1
- Pages
- 85-105
- ISSN
- 0098-5589 (ISSN-L)
- 1939-3520
- 2326-3881
- OpenAlex
- W4389104713
- Cited by
- 431
- References
- 70
- Citations by year
- 2026: 164 · 2025: 187 · 2024: 78
- FWCI
- 299.17
- Type
- journal article
- Language
- en
- Open access
- green
- arxiv.org
- Licence
- Locations
- IEEE Transactions on Software Engineering (publishedVersion)
- arXiv (Cornell University) (submittedVersion)
- arXiv (Cornell University)
- Funders
- National Science Foundation (CCF-1907727, CCF-2307742)
- Canada Research Chairs
- Natural Sciences and Engineering Research Council of Canada (RGPIN-2017-04289)
- 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
- automated unit test generation, large language models, prompt engineering, JavaScript, LLM model comparison, StarCoder, npm packages
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.