Generating Accurate Assert Statements for Unit Test Cases using Pretrained Transformers
Not on the map. Why?
Abstract (arXiv)
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 tests. The resulting model is able to generate accurate assert statements for a given method under test. In our empirical evaluation, the model was able to predict the exact assert statements written by developers in 62% of the cases in the first attempt. The results show 80% relative improvement for top-1 accuracy over the previous RNN-based approach in the literature. We also show the substantial impact of the pretraining process on the performances of our model, as well as comparing it with assert auto-completion task. Finally, we demonstrate how our approach can be used to augment EvoSuite test cases, with additional asserts leading to improved test coverage.
Key facts. Cited by 30 papers in the map (data through 7 Oct 2026). First posted on arXiv 11 Sep 2020.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2021: 3; 2022: 4; 2023: 7; 2024: 4; 2025: 7; 2026: 5.
30 papers.
Sort:
By area:
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 2023Planning with Large Language Models for Code Generationcited by 179
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?cited by 53
- 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
- 2021What do pre-trained code models know about code?cited by 36
- 2022Training and Evaluating a Jupyter Notebook Data Science Assistantcited by 31
- 2021Long-Range Modeling of Source Code Files with eWASH: Extended Window Access by Syntax Hierarchycited by 14
- 2024B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Testscited by 9
- 2023Domain Adaptation for Code Model-based Unit Test Case Generationcited by 7
- 2023Assessing Evaluation Metrics for Neural Test Oracle Generationcited by 7
- 2022On The Cross-Modal Transfer from Natural Language to Code through Adapter Modulescited by 6
- 2023Perfect is the enemy of test oraclecited by 6
18 more
- 2023Revisiting and Improving Retrieval-Augmented Deep Assertion Generationcited by 5
- 2025Beyond Postconditions: Can Large Language Models infer Formal Contracts for Automatic Software Verification?cited by 5
- 2025Generative AI for Self-Adaptive Systems: State of the Art and Research Roadmapcited by 5
- 2024exLong: Generating Exceptional Behavior Tests with Large Language Modelscited by 4
- 2024CodeSift: An LLM-Based Reference-Less Framework for Automatic Code Validationcited by 4
- 2025Improving Deep Assertion Generation via Fine-Tuning Retrieval-Augmented Pre-trained Language Modelscited by 4
- 2022AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representationscited by 3
- 2024LLMs in the Heart of Differential Testing: A Case Study on a Medical Rule Enginecited by 2
- 2025Improving Retrieval-Augmented Deep Assertion Generation via Joint Trainingcited by 2
- 2025Large Language Models for Software Testing: A Research Roadmapcited by 2
- 2026Understanding LLM-Driven Test Oracle Generationcited by 2
- 2026SpecMind: Cognitively Inspired, Interactive Multi-Turn Framework for Postcondition Inferencecited by 2
- 2025Static Program Analysis Guided LLM Based Unit Test Generationcited by 1
- 2026Teaching Code LLMs to Reason with Intermediate Formal Specificationscited by 1
- 2026SCATE: Learning to Supervise Coding Agents for Cost-Effective Test Generationcited by 1
- 2021Embedding Code Contexts for Cryptographic API Suggestion:New Methodologies and Comparisonscited by 0
- 2025CUBETESTERAI: Automated JUnit Test Generation using the LLaMA Modelcited by 0
- 2026Fail-Aware and Explainable Test Oracle Predictioncited by 0
- 2026Fail-Aware and Explainable Test Oracle Prediction13 Jul 2026
- 2026SCATE: Learning to Supervise Coding Agents for Cost-Effective Test Generation9 Jul 2026
- 2026Teaching Code LLMs to Reason with Intermediate Formal Specifications5 Jul 2026
- 2026SpecMind: Cognitively Inspired, Interactive Multi-Turn Framework for Postcondition Inference24 Feb 2026
- 2026Understanding LLM-Driven Test Oracle Generation9 Jan 2026
- 2025Generative AI for Self-Adaptive Systems: State of the Art and Research Roadmap4 Dec 2025
- 2025Beyond Postconditions: Can Large Language Models infer Formal Contracts for Automatic Software Verification?14 Oct 2025
- 2025Large Language Models for Software Testing: A Research Roadmap29 Sep 2025
- 2025CUBETESTERAI: Automated JUnit Test Generation using the LLaMA Model13 Mar 2025
- 2025Static Program Analysis Guided LLM Based Unit Test Generation7 Mar 2025
- 2025Improving Deep Assertion Generation via Fine-Tuning Retrieval-Augmented Pre-trained Language Models22 Feb 2025
- 2025Improving Retrieval-Augmented Deep Assertion Generation via Joint Training15 Feb 2025
18 more
- 2024B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Tests13 Sep 2024
- 2024CodeSift: An LLM-Based Reference-Less Framework for Automatic Code Validation28 Aug 2024
- 2024exLong: Generating Exceptional Behavior Tests with Large Language Models23 May 2024
- 2024LLMs in the Heart of Differential Testing: A Case Study on a Medical Rule Engine16 Feb 2024
- 2023Assessing Evaluation Metrics for Neural Test Oracle Generation11 Oct 2023
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?3 Oct 2023
- 2023Revisiting and Improving Retrieval-Augmented Deep Assertion Generation19 Sep 2023
- 2023Domain Adaptation for Code Model-based Unit Test Case Generation15 Aug 2023
- 2023Planning with Large Language Models for Code Generation9 Mar 2023
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generation13 Feb 2023
- 2023Perfect is the enemy of test oracle3 Feb 2023
- 2022Interactive Code Generation via Test-Driven User-Intent Formalization11 Aug 2022
- 2022AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representations23 May 2022
- 2022On The Cross-Modal Transfer from Natural Language to Code through Adapter Modules19 Apr 2022
- 2022Training and Evaluating a Jupyter Notebook Data Science Assistant30 Jan 2022
- 2021Long-Range Modeling of Source Code Files with eWASH: Extended Window Access by Syntax Hierarchy17 Sep 2021
- 2021What do pre-trained code models know about code?25 Aug 2021
- 2021Embedding Code Contexts for Cryptographic API Suggestion:New Methodologies and Comparisons15 Mar 2021
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 2023Planning with Large Language Models for Code Generationcited by 179
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?cited by 53
- 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
- 2021What do pre-trained code models know about code?cited by 36
- 2022Training and Evaluating a Jupyter Notebook Data Science Assistantcited by 31
- 2021Long-Range Modeling of Source Code Files with eWASH: Extended Window Access by Syntax Hierarchycited by 14
- 2024B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Testscited by 9
- 2023Domain Adaptation for Code Model-based Unit Test Case Generationcited by 7
- 2023Assessing Evaluation Metrics for Neural Test Oracle Generationcited by 7
- 2022On The Cross-Modal Transfer from Natural Language to Code through Adapter Modulescited by 6
- 2023Perfect is the enemy of test oraclecited by 6
12 most cited of 25 All 25 (JSON)
- 2026Fail-Aware and Explainable Test Oracle Prediction13 Jul 2026
- 2026SpecMind: Cognitively Inspired, Interactive Multi-Turn Framework for Postcondition Inference24 Feb 2026
- 2026Understanding LLM-Driven Test Oracle Generation9 Jan 2026
- 2025Generative AI for Self-Adaptive Systems: State of the Art and Research Roadmap4 Dec 2025
- 2025Beyond Postconditions: Can Large Language Models infer Formal Contracts for Automatic Software Verification?14 Oct 2025
- 2025Large Language Models for Software Testing: A Research Roadmap29 Sep 2025
- 2025CUBETESTERAI: Automated JUnit Test Generation using the LLaMA Model13 Mar 2025
- 2025Static Program Analysis Guided LLM Based Unit Test Generation7 Mar 2025
- 2024B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Tests13 Sep 2024
- 2024CodeSift: An LLM-Based Reference-Less Framework for Automatic Code Validation28 Aug 2024
- 2024exLong: Generating Exceptional Behavior Tests with Large Language Models23 May 2024
- 2024LLMs in the Heart of Differential Testing: A Case Study on a Medical Rule Engine16 Feb 2024
12 newest of 25 All 25 (JSON)