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

Please sign up or login with your details

Forgot password? Click here to reset