Learning Deep Semantics for Test Completion
Authors:
Top Cited Papers
- 1 May 2023
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 2111-2123
Abstract
Writing tests is a time-consuming yet essential task during software development. We propose to leverage recent advances in deep learning for text and code generation to assist developers in writing tests. We formalize the novel task of test completion to automatically complete the next statement in a test method based on the context of prior statements and the code under test. We develop TECo-a deep learning model using code semantics for test completion. The key insight underlying TECO is that predicting the next statement in a test method requires reasoning about code execution, which is hard to do with only syntax-level data that existing code completion models use. Teco extracts and uses six kinds of code semantics data, including the execution result of prior statements and the execution context of the test method. To provide a testbed for this new task, as well as to evaluate TECO, we collect a corpus of 130,934 test methods from 1,270 open-source Java projects. Our results show that Teco achieves an exact-match accuracy of 18, which is 29% higher than the best baseline using syntax-level data only. When measuring functional correctness of generated next statement, Teco can generate runnable code in 29% of the cases compared to 18% obtained by the best baseline. Moreover, Teco is sianificantly better than prior work on test oracle generation.Keywords
All Related Versions
This publication has 54 references indexed in Scilit:
- Automatically recommending test code examples to inexperienced developers2015
- EvoSuite2011
- Improving code completion with program historyAutomated Software Engineering, 2010
- Learning from examples to improve code completion systems2009
- Testing across configurationsACM SIGSOFT Software Engineering Notes, 2006
- ORANGE2004
- BLEU2001
- Experimentation as a way of life: Okapi at TRECInformation Processing & Management, 2000
- Long Short-Term MemoryNeural Computation, 1997
- Learning representations by back-propagating errorsNature, 1986