Generating Accurate Assert Statements for Unit Test Cases using Pretrained Transformers
Michele Tufano, Dawn Drain, Alexey Svyatkovskiy, Neel Sundaresan

TL;DR
This paper introduces a transformer-based model trained on source code to generate accurate assert statements for unit tests, significantly improving over previous methods and enhancing test coverage.
Contribution
The paper presents a novel transformer-based approach for generating assert statements in unit tests, leveraging pretraining and fine-tuning on source code data.
Findings
62% exact match rate in first attempt
80% relative improvement over RNN-based approach
Enhanced test coverage with augmented EvoSuite tests
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
