Revisiting and Improving Retrieval-Augmented Deep Assertion Generation

09/19/2023
by   Weifeng Sun, et al.
0

Unit testing validates the correctness of the unit under test and has become an essential activity in software development process. A unit test consists of a test prefix that drives the unit under test into a particular state, and a test oracle (e.g., assertion), which specifies the behavior in that state. To reduce manual efforts in conducting unit testing, Yu et al. proposed an integrated approach (integration for short), combining information retrieval (IR) with a deep learning-based approach, to generate assertions for a unit test. Despite promising, there is still a knowledge gap as to why or where integration works or does not work. In this paper, we describe an in-depth analysis of the effectiveness of integration. Our analysis shows that: 1) The overall performance of integration is mainly due to its success in retrieving assertions. 2) integration struggles to understand the semantic differences between the retrieved focal-test (focal-test includes a test prefix and a unit under test) and the input focal-test; 3) integration is limited to specific types of edit operations and cannot handle token addition or deletion. To improve the effectiveness of assertion generation, this paper proposes a novel retrieve-and-edit approach named EditAS. Specifically, EditAS first retrieves a similar focal-test from a pre-defined corpus and treats its assertion as a prototype. Then, EditAS reuses the information in the prototype and edits the prototype automatically. EditAS is more generalizable than integration. We conduct experiments on two large-scale datasets and experimental results demonstrate that EditAS outperforms the state-of-the-art approaches, with an average improvement of 10.00 score, respectively.

READ FULL TEXT

page 1

page 5

research
08/26/2023

EditSum: A Retrieve-and-Edit Framework for Source Code Summarization

Existing studies show that code summaries help developers understand and...
research
09/20/2021

Neural Unit Test Suggestions

Testing is widely recognized as an important stage of the software devel...
research
08/28/2018

Is Unit Testing Immune to Coincidental Correctness?

Researchers have previously shown that Coincidental Correctness (CC) is ...
research
07/27/2021

Yet Another Combination of IR- and Neural-based Comment Generation

Code comment generation techniques aim to generate natural language desc...
research
08/28/2018

Does the Testing Level affect the Prevalence of Coincidental Correctness?

Researchers have previously shown that Coincidental Correctness (CC) is ...
research
09/14/2023

Coverage Goal Selector for Combining Multiple Criteria in Search-Based Unit Test Generation

Unit testing is critical to the software development process, ensuring t...
research
04/23/2021

Structuring and presenting data for testing of automotive electronics to reduce effort during decision making

Automotive engineering is recognized as a combination of software and me...

Please sign up or login with your details

Forgot password? Click here to reset