Unit Test Case Generation with Transformers and Focal Context
Michele Tufano, Dawn Drain, Alexey Svyatkovskiy, Shao Kun Deng, Neel Sundaresan M. Tufano, D. Drain, A. Svyatkovskiy, S. K. Deng, N. Sundaresan are with Microsoft, Redmond, WA, USA. E-mail: {mitufano, dadrain, alsvyatk, shade,
Abstract
Software testing is a critical part of software development life cycle which helps identify potential regressions and reduce maintenance costs, yet it is often neglected by developers. Automated unit test case generation tools facilitate test-driven development and support developers by suggesting tests intended to identify flaws in their code. Existing approaches are usually guided by the test coverage criteria, generating synthetic test cases that are often difficult for developers to read or understand. In this paper we propose AthenaTest, an approach that aims to generate unit test cases by learning from real-world focal methods and developer-written test cases. We formulate unit test case generation as a sequence-to-sequence learning task, adopting a two-step training procedure consisting of denoising pretraining on a large unsupervised Java corpus, and supervised finetuning for a downstream translation task of generating unit tests. We investigate the impact of natural language and source code pretraining, as well as the focal context information surrounding the focal method. We found that both techniques provide improvements in terms of validation loss, with pretraining yiel
原文 arXiv:2009.05617;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2009.05617v2