October 26, 2026
Evolution of LLMs in unit test generation: evaluation of GPT-5.4
Alberto da Silva Candido; Ana Beatriz Lopes Françoso
DOI: 10.22167/2675-6528-202600481
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
Unit test generation is a laborious task that limits its adoption, but Large Language Models (LLMs) show potential to automate it. This study evaluated the GPT-5.4 model (released in March 2026) in generating unit tests for JavaScript, employing the TestPilot tool on 25 npm packages, and compared its results with those of GPT-3.5-Turbo. Data were collected through automated execution of TestPilot, recording instruction and branch coverage, the presence of non-trivial assertions, and failure types. GPT-5.4 achieved a median of 85.3% instruction coverage and 59.5% branch coverage, outperforming GPT-3.5-Turbo (70.2% and 52.8%, respectively). The proportion of valid tests reached 64.6%, and the rate of tests with non-trivial assertions was 96.2% (median). The self-correction rate based on error messages was 18.3%. It is inferred that GPT-5.4 represents an advancement in automated test generation, although issues such as timeouts and type errors still require human supervision.
Keywords: Large Language Models; Automated Test Generation; TestPilot; Unit Tests.
1. Introduction
Unit tests are fundamental in software development, configuring an essential practice for verifying the correct behavior of functions and methods. They facilitate early detection of failures and serve as a form of executable documentation, clarifying the system’s expected behavior (Khorikov, 2020). Despite their recognized importance, manual test writing is often neglected, as it is perceived as a time-consuming and costly process. This issue has driven the development of various test automation techniques over the past decades.
With the advancement of Large Language Models (LLMs), a new opportunity has emerged to automate this task. These models, trained on vast code repositories, demonstrate the ability to understand function semantics and generate code that resembles that produced by human developers (Wang & Chen, 2023). The application of LLMs in test generation has been a subject of growing interest, as evidenced by recent systematic reviews in the field.
Studies such as Zhang et al. (2025) analyzed 115 publications and proposed a taxonomy that divides the process of test generation with LLMs into two main stages: generation itself and quality assurance. This review highlighted that the prompt engineering technique is dominant in the field, present in 89% of the studies. Complementarily, Zapkus and Slotkienė (2024) provided a historical overview of the evolution of the main LLMs applied to test generation, discussing the parameters and characteristics of models such as GPT, CodeT5, and StarCoder.
In this context of advancements, Schäfer et al. (2024) developed TestPilot, a tool designed to orchestrate LLMs in generating unit tests for JavaScript. In their evaluation, GPT-3.5-Turbo, when used with TestPilot on 25 npm packages, demonstrated a median of 70.2% instruction coverage, significantly outperforming more traditional test generation techniques such as Nessie.
Since the initial evaluation of TestPilot, the evolution of LLMs has been remarkably rapid. In March 2026, OpenAI released GPT-5.4, announcing substantial improvements in reasoning capabilities, instruction adherence, and code generation quality. This rapid technological advancement raises a crucial question about the performance of the latest models in the context of automated test generation.
Given this evolution, the central question guiding this research is whether GPT-5.4 surpasses GPT-3.5-Turbo in the automated generation of unit tests, delivering code with greater coverage and more meaningful tests. The relevance of this study lies in the continuous need to evaluate the state of the art of LLMs applied to software engineering, providing updated empirical evidence. Such evidence is crucial for guiding professionals in the adoption of these tools and assisting LLM developers in identifying areas for improvement, ensuring that technological innovations translate into practical and measurable benefits.
To address this issue and contribute to the field, this work’s main objective is to evaluate the performance of the GPT-5.4 model in the automated generation of unit tests for JavaScript, using the TestPilot tool on a set of 25 npm packages, and to compare its results with those obtained by GPT-3.5-Turbo, recording metrics of coverage, validity, and assertion quality, identifying the most common types of failures and the effectiveness of the error feedback mechanism, in addition to making all research artifacts publicly available to ensure reproducibility.
2. Material and Methods
This work carried out an applied case study, focused on the performance evaluation of a large-scale language model in the automated generation of unit tests. The empirical object of the research consisted of each API function exposed by a predefined set of 25 npm packages. The data analysis approach was predominantly quantitative, complemented by a qualitative analysis of the types of failures and the nature of the generated assertions.
For the execution of the research, the TestPilot tool was used, developed by Schäfer et al. (2024) and available in a public repository (Schäfer et al., 2025). TestPilot orchestrates the interaction with language models to generate unit tests for JavaScript. The language model used was OpenAI’s GPT-5.4, accessed via API (v1/responses route), with parameters of temperature = 0, top-p = 1, maximum limit of 100 tokens per response and up to 5 samples per prompt, kept identical to those of the original study by Schäfer et al. (2024).
The dataset for the evaluation comprised the same 25 JavaScript packages used in the study by Schäfer et al. (2024). The selection of these packages spanned different domains, such as file systems, promises, data structures, and statistics, in addition to varying in popularity levels. Five packages hosted on GitLab, not present in the GPT-3.5-Turbo training set, were included to assess generalization capability. The obtained results were compared with the values reported for GPT-3.5-Turbo in the original study.
The TestPilot operated in a four-step main workflow. First, the API Explorer dynamically identified all exported functions from the packages under test, registering their access paths and signatures. Next, the Documentation Miner extracted documentation comments (doc comments) and code snippets from Markdown files, associating them with the respective identified functions.
The Prompt Generator stage built the initial prompts for the language model, containing the function signature, its body (source code), documentation, and usage examples, when available. Subsequently, the Prompt Refiner was triggered if a generated test failed. In this case, a new prompt was created, including the failed test and the error message, allowing the model to attempt to correct the test code.
For each package, TestPilot was executed, generating tests via API and saving a file with the resulting metrics. Each generated test was syntactically validated and then executed with the Mocha framework, setting a limit of 2 seconds per test. All generated source code, prompts, and execution logs were stored and made publicly available in a GitHub repository (Candido, 2026), ensuring research transparency and reproducibility.
Statement coverage and branch coverage were measured, considering only the tests that were successfully executed. Failures were classified according to the taxonomy of Schäfer et al. (2024), which included AssertionError, TimeoutError, CorrectnessError (type errors, reference errors, syntax errors, missing `done()` call), FileSystemError, and OtherError.
The presence of non-trivial assertions was determined by static analysis: a test was classified as non-trivial if it contained at least one assertion whose value depended on the execution of a function from the package under test. The quantitative metrics analyzed included the percentage of valid tests (tests that executed without error, excluding assertion failures), instruction and branch coverage (calculated on valid tests), the percentage of non-trivial tests, and the feedback correction rate (percentage of failing tests that became valid after refinement with an error message).
3. Results and Discussion
The evaluation of the GPT-5.4 model in the automated generation of unit tests for JavaScript revealed a significant advancement compared to its predecessor, GPT-3.5-Turbo. In total, 5,519 tests were generated for the 25 npm packages analyzed, of which 3,568 were considered valid, representing a proportion of 64.65%. This initial result already demonstrates a substantial improvement in the quality of the generated code, reflecting the model’s enhanced ability to produce executable and functional tests.
The proportion of valid tests achieved by GPT-5.4, at 64.6%, represents a gain of 16.6 percentage points compared to the average of 48.0% obtained by GPT-3.5-Turbo in the previous study (Schäfer et al., 2024). This increase in test validity suggests that GPT-5.4 has a more robust understanding of JavaScript package conventions and APIs, resulting in fewer syntax and reference errors. Detailed analysis by package revealed that, although the overall average was 64.65%, packages such as `node-jsonfile` (94.12%) and `pull-stream` (84.75%) demonstrated a high proportion of valid tests, while `crawler-url-parser` (5.26%) and `spacl-core` (27.08%) showed more modest results, indicating variability in the complexity and test generation capability for different domains.
Regarding code coverage, GPT-5.4 presented a median of 85.3% for statement coverage. This value is expressively higher than the median of 70.2% achieved by GPT-3.5-Turbo, representing an increase of 15.1 percentage points. This improvement indicates that the latest model is capable of exercising a significantly larger portion of the code lines of the functions under test, contributing to a more comprehensive verification of software behavior. Packages such as `simple-statistics` (97.07%) and `delta` (92.79%) demonstrated exceptionally high statement coverages, while `node-geo-point` (1.84%) and `node-graceful-fs` (46.45%) fell below the average, highlighting specific challenges.
Branch coverage also showed a notable advancement, with a median of 59.5% for GPT-5.4, surpassing GPT-3.5-Turbo’s 52.8%, which corresponds to a gain of 6.7 percentage points. This increase is crucial, as branch coverage assesses the ability of tests to explore different conditional paths and control structures within the code. The improvement suggests that GPT-5.4 understands and generates tests that exercise more complex scenarios. However, branch coverage still remains lower than instruction coverage, indicating that generating tests for edge cases or for conditions requiring specific configurations continues to be a challenge for the model, as observed in `node-graceful-fs` (10.56%) and `crawler-url-parser` (33.75%).
One of the most impactful findings was the proportion of tests with non-trivial assertions, which reached a median of 96.2% among the packages. This result is substantially higher than the 61.4% reported for GPT-3.5-Turbo. Non-trivial tests are those that contain assertions whose value depends on the execution of a function of the package under test, conferring practical utility and relevance to the generated tests. The improvement is particularly evident in packages where GPT-3.5-Turbo showed a low non-triviality rate, such as `jsonfile`, which went from 0% with the old model to 100% with GPT-5.4. This indicates that the newer model has better internalized the need to associate assertions with the expected behavior of the tested API, making the generated tests much more useful for developers.
The analysis of failure types in invalid tests generated by GPT-5.4 revealed important patterns. Compared to GPT-3.5-Turbo, the latest model demonstrated a 31% reduction in `FileSystemError` (errors related to file not found) and an 18% decrease in `CorrectnessError` (mainly type and reference errors). This reduction suggests a better understanding of the execution context and environment dependencies by GPT-5.4. However, `TimeoutError` remained frequent, representing a significant portion of failures. Most of these timeouts were attributed to the absence of the `done()` call in asynchronous tests, a pattern that the model has not yet fully internalized in all situations.
The error feedback mechanism, named `RetryWithError`, was triggered for 1,242 failed tests. Of these, 227 tests, corresponding to 18.3%, were successfully corrected after generating a second prompt that included the original error message. This self-correction rate is higher than the 15.6% reported for GPT-3.5-Turbo (Schäfer et al., 2024), indicating that GPT-5.4 more effectively leverages error feedback to adjust and refine test code. The improvement was more significant in correcting assertion errors, where the model learned to adjust expected values, and in timeouts caused by the lack of `done()`, where the model learned to add the necessary call.
The results obtained with GPT-5.4 demonstrate a consistent and multifaceted advancement compared to GPT-3.5-Turbo across all evaluated metrics. The most significant improvements include a higher proportion of valid tests, with a gain of 16.6 percentage points, substantially reducing the need for manual debugging. There was a significant increase in instruction coverage, with the median rising from 70.2% to 85.3%, and in branch coverage, which increased from 52.8% to 59.5%. Furthermore, the rate of tests with non-trivial assertions reached a median of 96.2%, making the generated tests significantly more useful, and the self-correction capability improved from 15.6% to 18.3%, decreasing the need for human intervention.
These findings are in line with recent literature that highlights the rapid evolution of Large Language Models and the importance of prompt engineering in code generation. Studies such as Zhang et al. (2025) and Zapkus and Slotkienė (2024) already pointed to the predominance of prompt engineering and the continuous need to evaluate the performance of new models. The ability of GPT-5.4 to generate tests with greater coverage and more meaningful assertions corroborates the thesis that the choice of model version and prompt structure directly affect quality metrics, as observed in works on test generation for REST APIs (Rincon et al., 2025).
Despite the advances, some limitations persist and demand attention. Branch coverage, although improved, still indicates that many conditional paths are not exercised, suggesting that the model still struggles to generate tests for all possible execution scenarios. `TimeoutError`, which represented 19.2% of failures, and `CorrectnessError`, with 30.6%, demonstrate that the model still makes type and reference errors, especially in more complex APIs or those with intense dynamic typing. Therefore, although GPT-5.4 is a powerful tool for test automation, human supervision remains necessary, mainly for validating asynchronous tests and creating edge scenarios.
In summary, the GPT-5.4 model represents a consistent advancement in the automated generation of unit tests for JavaScript, outperforming GPT-3.5-Turbo across all evaluated metrics, including validity, code coverage, assertion quality, and self-correction capability. The results indicate that the latest Large Language Models are approaching practical and reliable automation for unit test creation, although the need for human supervision persists to handle specific complexities and ensure the robustness of the generated tests.
4. Conclusion
This study evaluated the performance of the GPT-5.4 model in the automated generation of unit tests for JavaScript, using the TestPilot tool on 25 npm packages, and compared its results with those obtained by GPT-3.5-Turbo. It was found that GPT-5.4 consistently outperformed the previous model in all analyzed metrics. A significant increase was observed in the proportion of valid tests, which reached 64.6%, and in instruction coverage, with a median of 85.3%. Branch coverage also showed improvement, reaching 59.5%. Additionally, it was identified that 96.2% of the generated tests contained non-trivial assertions, giving them greater practical utility. The model’s self-correction capability, based on error messages, also proved superior, correcting 18.3% of failed tests. These findings demonstrate a remarkable advancement in the quality and effectiveness of automated unit test generation by Large Language Models, offering updated empirical evidence that can guide professionals in adopting these tools and assist in the continuous improvement of LLMs.
Despite the advances, some limitations were identified. Branch coverage, although improved, still indicates that many conditional paths are not exercised, and issues like TimeoutError and CorrectnessError persist, especially in more complex APIs or those with dynamic typing. This suggests that human supervision remains necessary to ensure test robustness, particularly in asynchronous and edge scenarios. As a practical contribution, all research artifacts were made publicly available, ensuring the reproducibility of the study. For future work, it is suggested to evaluate GPT-5.4 in other programming languages, explore the use of smaller, specialized models for cost optimization, incorporate cost metrics per generated test, and conduct user studies to measure the readability and practical utility of the produced tests.
Bibliographic References
Candido, A.S. 2026. TestPilot Experimento com GPT-5.4. GitHub. Disponível em: https://github.com/albertoscandido/testpilot. Acesso em: 20 abr. 2026.
Khorikov, V. 2020. Unit Testing: Principles, Practices, and Patterns. Manning Publications, Shelter Island, NY, USA.
Rincon, A.M.; Vincenzi, A.M.R.; Faria, J.P. 2025. LLM Prompt Engineering for Automated White-Box Integration Test Generation in REST APIs. In: 2025 IEEE International Conference on Software Testing, Verification and Validation Workshops (ICSTW), Naples, Italy. IEEE. p. 21-28. DOI: https://doi.org/10.1109/ICSTW64639.2025.10962507
Schäfer, M.; Nadi, S.; Eghbali, A.; Tip, F. 2024. An empirical evaluation of using large language models for automated unit test generation. IEEE Transactions on Software Engineering 50(1): 85-105.
Schäfer, M.; Tip, F.; Nadi, S. 2025. TestPilot. GitHub. Disponível em: https://github.com/githubnext/testpilot. Acesso em: 20 abr. 2026.
Wang, X.; Chen, Y. 2023. A review on code generation with LLMs: application and evaluation. In: 2023 IEEE International Conference on Medical Artificial Intelligence (MedAl 2023). Shanghai: IEEE. DOI: https://doi.org/10.1109/MEDAI59581.2023.00044
Zapkus, D.M.; Slotkienė, A. 2024. Unit test generation using large language models: a systematic literature review. In: Lietuvos magistrantų informatikos ir IT tyrimai: konferencijos darbai, 2024 m. gegužės 10 d. Vilnius: Vilniaus universiteto leidykla / Vilnius University Press. p. 136-144. DOI: https://doi.org/10.15388/LMITT.2024.20
Zhang, Q.; Fang, C.; Gu, S.; Shang, Y.; Chen, Z.; Xiao, L. 2025. Large Language Models for Unit Testing: A Systematic Literature Review. arXiv preprint. DOI: https://doi.org/10.48550/arXiv.2506.15227
Article originating from the Final Course Work of the Specialization in Software Engineering of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform