Revisiting and Improving Retrieval-Augmented Deep Assertion Generation
Weifeng Sun, Hongyan Li, Meng Yan, Yan Lei, Hongyu Zhang
Abstract
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 with a deep learning-based approach, to generate assertions for a unit test. Despite being 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: ① The overall performance of integration is mainly due to its success in retrieving assertions. ② 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, resulting in many tokens being incorrectly modified; ③ integration is limited to specific types of edit operations (i.e., replacement) 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 because it can ❶ comprehensively understand the semantic differences between input and similar focal-tests; ❷ apply appropriate assertion edit patterns with greater flexibility; and ❸ generate more diverse edit actions than just replacement operations. We conduct experiments on two large-scale datasets and the experimental results demonstrate that Editas outperforms the state-of-the-art approaches, with an average improvement of 10.00%-87.48% and 3.30%-42.65% in accuracy and BLEU score, respectively.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 2ac016c6-7160-4f62-bf49-21237e9331f4Cited by top-tier papers3
- On the Evaluation of Large Language Models in Unit Test GenerationLin Yang, Chen Yang, Shutao Gao, Weijing Wang et al.ASE 2024 · 42 citations
- ProofFusion: Improving Neural Theorem Proving via Adaptive Retrieval-Augmented ReasoningManqing Zhang, Yunwei Dong, Lingru Zhou, Bingxu Xiao et al.FSE 2026
- Understanding and Improving Model Editing for Secure Code GenerationWeifeng Sun, Quanjun Zhang, Yuchen Chen, Chengran Yang et al.ISSTA 2026
Builds on9
- Retrieval-based neural source code summarizationJian Zhang, Xu Wang, Hongyu Zhang, Hailong Sun et al.ICSE 2020 · 242 citations
- Boosting coverage-based fault localization via graph-based representation learningYiling Lou, Qihao Zhu, Jinhao Dong, Xia Li et al.FSE 2021 · 157 citations
- On learning meaningful assert statements for unit test casesCody Watson, Michele Tufano, Kevin Moran, Gabriele Bavota et al.ICSE 2020 · 96 citations
- TOGA: A Neural Method for Test Oracle GenerationElizabeth Dinella, Gabriel Ryan, Todd Mytkowicz, Shuvendu K. LahiriICSE 2022 · 92 citations
- EditSum: A Retrieve-and-Edit Framework for Source Code SummarizationJia Li, Yongmin Li, Ge Li, Xing Hu et al.ASE 2021 · 55 citations
Related papers
- Automated Assertion Generation via Information Retrieval and Its Integration with Deep learningHao Yu, Yiling Lou, Ke Sun, Dezhi Ran et al.ICSE 2022 · 42 citations
- An Empirical Study on Focal Methods in Deep-Learning-Based Approaches for Assertion GenerationYibo He, Jiaming Huang, Hao Yu, Tao XieFSE 2024 · 8 citations
- STARS: Static Analysis-Guided Assertion Synthesis using Large Language ModelsJialun Cao, Haoyu Wang, Haoran Yan, Ming Wen et al.ISSTA 2026
- What You See is What You Get: Attention-Based Self-Guided Automatic Unit Test GenerationXin Yin, Chao Ni, Xiaodan Xu, Xiaohu YangICSE 2025 · 8 citations
- UTFix: Change Aware Unit Test Repairing using LLMShanto Rahman, Sachit Kuhar, Berk Çirisci, Pranav Garg et al.OOPSLA 2025 · 9 citations
