Unit Test Case Generation with Transformers
Auteurs : Michele Tufano, Dawn Drain, Alexey Svyatkovskiy, Shao Kun Deng, Neel Sundaresan
Résumé scientifique
Automated Unit Test Case generation has been the focus of extensive literature within the research community. Existing approaches are usually guided by the test coverage criteria, generating synthetic test cases that are often difficult to read or understand for developers. In this paper we propose AthenaTest, an approach that aims at generating unit test cases by learning from real-world, developer-written test cases. Our approach relies on a state-of-the-art sequence-to-sequence transformer model which is able to write useful test cases for a given method under test (i.e., focal method). We also introduce methods2test - the largest publicly available supervised parallel corpus of unit test case methods and corresponding focal methods in Java, which comprises 630k test cases mined from 70k open-source repositories hosted on GitHub. We use this dataset to train a transformer model to translate focal methods into the corresponding test cases. We evaluate the ability of our model in generating test cases using natural language processing as well as code-specific criteria. First, we assess the quality of the translation compared to the target test case, then we analyze properties of the test case such as syntactic correctness and number and variety of testing APIs (e.g., asserts). We execute the test cases, collect test coverage information, and compare them with test cases generated by EvoSuite and GPT-3. Finally, we survey professional developers on their preference in terms of readability, understandability, and testing effectiveness of the generated test cases.
Les articles autour de lui, par date et par proximité
Plus haut, c’est plus proche de cet article ; à gauche, c’est plus ancien. Les traits relient les articles proches entre eux : les groupes de traits sont des sous-thèmes. Sélectionnez un point pour voir pourquoi il est là. Retour au résumé de cet article
Les articles autour de celui-ci
Classés selon la proximité de leur titre et de leur résumé avec ceux de cet article. Sélectionnez-en pour les lire ensemble.
Les articles les plus proches
-
Transformer-Based Unit Test GenerationK. A. Rafique, Pooja J. Biradar, Christoph Grimm · 2025 · Conference on Algebraic Informatics · cité 1 fois · Pas encore résumé
Résumé scientifique
Automated test case generation reduces the manual effort of software testing, particularly for dynamic languages like Python. This study compares three transformer-based models-CodeT5, CodeBERT, and CodeGen. While CodeBERT and CodeGen were expected to excel due to their focus on code understanding and generation, CodeT5, a code summarization model, outperformed both, achieving higher code coverage and superior semantic and syntactic fidelity. Using a limited yet diverse dataset of Python functions with natural language descriptions and unit tests, we evaluated models with NLP metrics (BLEU, ROUGE-L) and practical measures like code coverage. CodeGen struggled with coherence under data constr…
-
Reimagining Unit Test Generation With AI: A Journey From Evolutionary Models to TransformersSintayehu Zekarias Esubalew, Beakal Gizachew Assefa · 2025 · IEEE Access · cité 1 fois · Pas encore résumé
Résumé scientifique
The rapid evolution of software development necessitates efficient unit testing to ensure reliability, yet manual test case generation is labor-intensive and often inadequate for agile workflows. Despite advancements, a comprehensive review of AI-driven unit test case generation, particularly for Java, is lacking, motivating this study to address this gap. The paper examines AI algorithms for unit test case generation, focusing on Java-specific challenges like class hierarchies and dependency injection. We propose a novel taxonomy categorizing methods into traditional machine learning (e.g., genetic algorithms, SVMs), deep learning (e.g., RNNs, GNNs), and transformer-based approaches (e.g., …
-
Generating Accurate Assert Statements for Unit Test Cases using Pretrained TransformersMichele Tufano, Dawn Drain, Alexey Svyatkovskiy et al. · 2020 · International Conference/Workshop on Automation of Software Test · cité 144 fois · Pas encore résumé
Résumé scientifique
Unit testing represents the foundational basis of the software testing pyramid, beneath integration and end-to-end testing. Automated software testing researchers have proposed a variety of techniques to assist developers in this time-consuming task. In this paper we present an approach to support developers in writing unit test cases by generating accurate and useful assert statements. Our approach is based on a state-of-the-art transformer model initially pretrained on an English textual corpus. This semantically rich model is then trained in a semi-supervised fashion on a large corpus of source code. Finally, we finetune this model on the task of generating assert statements for unit test…
-
From Fine-tuning to Output: An Empirical Investigation of Test Smells in Transformer-Based Test Code GenerationAhmed Aljohani, Hyunsook Do · 2024 · ACM Symposium on Applied Computing · cité 10 fois · Pas encore résumé
Résumé scientifique
Researchers have recently leveraged transformer-based test code generation models to improve testing-related tasks (e.g., assert completion and test method generation). One such model, AthenaTest, has been recently introduced, and it has been well accepted by developers due to its ability to generate test cases similar to the ones written by developers. While the AthenaTest model provides adequate test coverage and improves test code readability, concerns remain regarding the quality of its generated test code, particularly the presence of test smells, which could degrade the test code's comprehension, readability, performance, and maintainability. In this paper, we investigated whether test…
-
A3Test: Assertion-Augmented Automated Test Case GenerationSaranya Alagarsamy, C. Tantithamthavorn, A. Aleti · 2023 · Information and Software Technology · cité 133 fois · Pas encore résumé
Résumé scientifique
Test case generation is an important activity, yet a time-consuming and laborious task. Recently, AthenaTest -- a deep learning approach for generating unit test cases -- is proposed. However, AthenaTest can generate less than one-fifth of the test cases correctly, due to a lack of assertion knowledge and test signature verification. In this paper, we propose A3Test, a DL-based test case generation approach that is augmented by assertion knowledge with a mechanism to verify naming consistency and test signatures. A3Test leverages the domain adaptation principles where the goal is to adapt the existing knowledge from an assertion generation task to the test case generation task. We also intro…
-
Domain Adaptation for Code Model-Based Unit Test Case GenerationJiho Shin, S. Hashtroudi, H. Hemmati et al. · 2023 · International Symposium on Software Testing and Analysis · cité 41 fois · Pas encore résumé
Résumé scientifique
Recently, deep learning-based test case generation approaches have been proposed to automate the generation of unit test cases. In this study, we leverage Transformer-based code models to generate unit tests with the help of Domain Adaptation (DA) at a project level. Specifically, we use CodeT5, a relatively small language model trained on source code data, and fine-tune it on the test generation task. Then, we apply domain adaptation to each target project data to learn project-specific knowledge (project-level DA). We use the Methods2test dataset to fine-tune CodeT5 for the test generation task and the Defects4j dataset for project-level domain adaptation and evaluation. We compare our app…
-
Exploring the Effectiveness of Large Language Models in Generating Unit TestsMohammed Latif Siddiq, Joanna C. S. Santos, Ridwanul Hasan Tanvir et al. · 2023 · Software Engineering · cité 138 fois · Résumé IA disponible
Résumé scientifique
A code generation model generates code by taking a prompt from a code comment, existing code, or a combination of both. Although code generation models (e.g., GitHub Copilot) are increasingly being adopted in practice, it is unclear whether they can successfully be used for unit test generation without fine-tuning. To fill this gap, we investigated how well three generative models (CodeGen, Codex, and GPT-3.5) can generate test cases. We used two benchmarks (HumanEval and Evosuite SF110) to investigate the context generation's effect in the unit test generation process. We evaluated the models based on compilation rates, test correctness, coverage, and test smells. We found that the Codex mo…
-
A3Test: Assertion-Augmented Automated Test case generationSaranya Alagarsamy, Chakkrit Kla Tantithamthavorn, Aldeida Aleti · 2024 · Information and Software Technology · cité 96 fois · Pas encore résumé
Résumé scientifique
Context: Test case generation is a critical yet challenging task in software development. Recently, AthenaTest – a Deep Learning (DL) approach for generating unit test cases has been proposed. However, our revisiting study reveals that AthenaTest can generate less than one-fifth of the test cases correctly, due to a lack of assertion knowledge and test signature verification. Objective: This paper introduces A3Test, a novel DL-based approach to the generation of test cases, enhanced with assertion knowledge and a mechanism to verify consistency of the name and signatures of the tests. A3Test aims to adapt domain knowledge from assertion generation to test case generation. Method: A3Test empl…
Les travaux antérieurs sur lesquels il s’appuie
-
An Empirical Investigation on the Readability of Manual and Generated Test CasesGiovanni Grano, Simone Scalabrino, H. Gall et al. · 2018 · IEEE International Conference on Program Comprehension · cité 82 fois · Pas encore résumé
Résumé scientifique
Software testing is one of the most crucial tasks in the typical development process. Developers are usually required to write unit test cases for the code they implement. Since this is a time-consuming task, in last years many approaches and tools for automatic test case generation — such as EvoSuite — have been introduced. Nevertheless, developers have to maintain and evolve tests to sustain the changes in the source code; therefore, having readable test cases is important to ease such a process. However, it is still not clear whether developers make an effort in writing readable unit tests. Therefore, in this paper, we conduct an explorative study comparing the readability of manually wri…
-
On Learning Meaningful Assert Statements for Unit Test CasesCody Watson, Michele Tufano, Kevin Moran et al. · 2020 · International Conference on Software Engineering · cité 220 fois · Pas encore résumé
Résumé scientifique
Software testing is an essential part of the software lifecycle and requires a substantial amount of time and effort. It has been estimated that software developers spend close to 50% of their time on testing the code they write. For these reasons, a long standing goal within the research community is to (partially) automate software testing. While several techniques and tools have been proposed to automatically generate test methods, recent work has criticized the quality and usefulness of the assert statements they generate. Therefore, we employ a Neural Machine Translation (NMT) based approach called Atlas (AuTomatic Learning of Assert Statements) to automatically generate meaningful asse…
-
Automatic test case generation: what if test code quality matters?Fabio Palomba, Annibale Panichella, A. Zaidman et al. · 2016 · International Symposium on Software Testing and Analysis · cité 70 fois · Pas encore résumé
-
Automated unit test generation for evolving softwareS. Shamshiri · 2015 · ESEC/SIGSOFT FSE · cité 35 fois · Pas encore résumé
-
Exploring the Limits of Transfer Learning with a Unified Text-to-Text TransformerColin Raffel, Noam Shazeer, Adam Roberts et al. · 2019 · Machine Learning · cité 28 272 fois · Résumé IA disponible
Résumé scientifique
Transfer learning, where a model is first pre-trained on a data-rich task before being fine-tuned on a downstream task, has emerged as a powerful technique in natural language processing (NLP). The effectiveness of transfer learning has given rise to a diversity of approaches, methodology, and practice. In this paper, we explore the landscape of transfer learning techniques for NLP by introducing a unified framework that converts all text-based language problems into a text-to-text format. Our systematic study compares pre-training objectives, architectures, unlabeled data sets, transfer approaches, and other factors on dozens of language understanding tasks. By combining the insights from o…
Les articles qui le citent
-
Evaluating and Improving ChatGPT for Unit Test GenerationZhi-Qiang Yuan, Ming-Wei Liu, Shiji Ding et al. · 2024 · Proc. ACM Softw. Eng. · cité 275 fois · Pas encore résumé
Résumé scientifique
Unit testing plays an essential role in detecting bugs in functionally-discrete program units (e.g., methods). Manually writing high-quality unit tests is time-consuming and laborious. Although the traditional techniques are able to generate tests with reasonable coverage, they are shown to exhibit low readability and still cannot be directly adopted by developers in practice. Recent work has shown the large potential of large language models (LLMs) in unit test generation. By being pre-trained on a massive developer-written code corpus, the models are capable of generating more human-like and meaningful test code. In this work, we perform the first empirical study to evaluate the capability…
-
No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test GenerationZhi-Qiang Yuan, Yiling Lou, Ming-Wei Liu et al. · 2023 · arXiv.org · preprint, non relu par les pairs · cité 239 fois · Pas encore résumé
Résumé scientifique
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…
-
TOGA: A Neural Method for Test Oracle GenerationElizabeth Dinella, Gabriel Ryan, T. Mytkowicz et al. · 2021 · International Conference on Software Engineering · cité 218 fois · Pas encore résumé
Résumé scientifique
Testing is widely recognized as an important stage of the software development lifecycle. Effective software testing can provide benefits such as bug finding, preventing regressions, and documentation. In terms of documentation, unit tests express a unit's intended functionality, as conceived by the developer. A test oracle, typically expressed as an condition, documents the intended behavior of a unit under a given test prefix. Synthesizing a functional test oracle is a challenging problem, as it must capture the intended functionality rather than the implemented functionality. In this paper, we propose TOGA (a neural method for Test Oracle GenerAtion), a unified transformer-based neural ap…
-
An Empirical Study of Unit Test Generation with Large Language ModelsLin Yang, Chen Yang, Shutao Gao et al. · 2024 · Software Engineering · cité 169 fois · Résumé IA disponible
Résumé scientifique
Unit testing is an essential activity in software development for verifying the correctness of software components. However, manually writing unit tests is challenging and time-consuming. The emergence of Large Language Models (LLMs) offers a new direction for automating unit test generation. Existing research primarily focuses on closed-source LLMs (e.g., ChatGPT and CodeX) with fixed prompting strategies, leaving the capabilities of advanced open-source LLMs with various prompting settings unexplored. Particularly, open-source LLMs offer advantages in data privacy protection and have demonstrated superior performance in some tasks. Moreover, effective prompting is crucial for maximizing LL…
-
An Empirical Evaluation of Using Large Language Models for Automated Unit Test GenerationMax Schäfer, Sarah Nadi, Aryaz Eghbali et al. · 2023 · IEEE Transactions on Software Engineering · cité 508 fois · Pas encore résumé
Résumé scientifique
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 signatur…
Aller plus loin
Comment ces articles sont-ils trouvés ?
Nous comparons le titre et le résumé de cet article avec ceux de tous les articles résumés sur ce site, et avec les articles que Semantic Scholar recommande, ceux qu’il cite et ceux qui le citent (pour un article très cité, ses citations les plus récentes et, depuis OpenAlex, les plus citées). Parmi les travaux antérieurs et les suites, les articles qui s’utilisent en profondeur, une méthode qu’il utilise et les suites très citées remontent un peu. Les niveaux (très proche, proche, apparenté) viennent de la similarité des textes, pas d’un jugement de qualité ; * signale un article sans résumé, comparé par son titre. La phrase sous un article est écrite par une IA à partir des deux résumés : vérifiez-la dans les articles. Un article jugé hors sujet par trois lecteurs quitte la liste.
Mis à jour le 5 novembre 2026.