On Learning Meaningful Assert Statements for Unit Test Cases

02/13/2020
by   Cody Watson, et al.
0

Software testing is an essential part of the software lifecycle andrequires a substantial amount of time and effort. It has been esti-mated that software developers spend close to 50 these reasons, a long standing goalwithin the research community is to (partially) automate softwaretesting. While several techniques and tools have been proposedto automatically generate test methods, recent work has criticizedthe quality and usefulness of the assert statements they generate.Therefore, we employ a Neural Machine Translation (NMT) basedapproach calledAtlas(AuTomaticLearning ofAssertStatements)to automatically generate meaningful assert statements for testmethods. Given a test method and a focal method (i.e.,the mainmethod under test),Atlascan predict a meaningful assert state-ment to assess the correctness of the focal method. We appliedAtlasto thousands of test methods from GitHub projects and itwas able to predict the exact assert statement manually writtenby developers in 31 only considering the top-1 predicted assert. When considering the top-5 predicted assertstatements,Atlasis able to predict exact matches in 50 thecases. These promising results hint to the potential usefulness ofour approach as (i) a complement to automatic test case generationtechniques, and (ii) a code completion support for developers, whocan benefit from the recommended assert statements while writingtest code.

READ FULL TEXT
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
02/20/2023

Learning Deep Semantics for Test Completion

Writing tests is a time-consuming yet essential task during software dev...
research
09/02/2021

APIzation: Generating Reusable APIs from StackOverflow Code Snippets

Developer forums like StackOverflow have become essential resources to m...
research
10/26/2021

Automated Support for Unit Test Generation: A Tutorial Book Chapter

Unit testing is a stage of testing where the smallest segment of code th...
research
01/25/2019

On Learning Meaningful Code Changes via Neural Machine Translation

Recent years have seen the rise of Deep Learning (DL) techniques applied...
research
12/02/2021

Borrowing from Similar Code: A Deep Learning NLP-Based Approach for Log Statement Automation

Software developers embed logging statements inside the source code as a...
research
12/20/2018

An Empirical Study on Learning Bug-Fixing Patches in the Wild via Neural Machine Translation

Millions of open-source projects with numerous bug fixes are available i...

Please sign up or login with your details

Forgot password? Click here to reset