Learning Deep Semantics for Test Completion

02/20/2023
by   Pengyu Nie, et al.
0

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 Moreover, TeCo is significantly better than prior work on test oracle generation.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/13/2020

On Learning Meaningful Assert Statements for Unit Test Cases

Software testing is an essential part of the software lifecycle andrequi...
research
11/19/2020

ReAssert: Deep Learning for Assert Generation

The automated generation of test code can reduce the time and effort req...
research
03/17/2021

Code Completion by Modeling Flattened Abstract Syntax Trees as Graphs

Code completion has become an essential component of integrated developm...
research
08/17/2022

CCTEST: Testing and Repairing Code Completion Systems

Code completion, a highly valuable topic in the software development dom...
research
09/11/2020

Generating Accurate Assert Statements for Unit Test Cases using Pretrained Transformers

Unit testing represents the foundational basis of the software testing p...
research
09/02/2021

APIzation: Generating Reusable APIs from StackOverflow Code Snippets

Developer forums like StackOverflow have become essential resources to m...
research
11/18/2019

Combining Program Analysis and Statistical Language Model for Code Statement Completion

Automatic code completion helps improve developers' productivity in thei...

Please sign up or login with your details

Forgot password? Click here to reset