Improving Deep Assertion Generation via Fine-Tuning Retrieval-Augmented Pre-trained Language Models

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Zhang, Quanjun, Fang, Chunrong, Zheng, Yi, Zhang, Yaxin, Zhao, Yuan, Huang, Rubing, Zhou, Jianyi, Yang, Yun, Zheng, Tao, Chen, Zhenyu
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866910840755585024
author Zhang, Quanjun
Fang, Chunrong
Zheng, Yi
Zhang, Yaxin
Zhao, Yuan
Huang, Rubing
Zhou, Jianyi
Yang, Yun
Zheng, Tao
Chen, Zhenyu
author_facet Zhang, Quanjun
Fang, Chunrong
Zheng, Yi
Zhang, Yaxin
Zhao, Yuan
Huang, Rubing
Zhou, Jianyi
Yang, Yun
Zheng, Tao
Chen, Zhenyu
contents Unit testing validates the correctness of the units of the software system under test and serves as the cornerstone in improving software quality and reliability. To reduce manual efforts in writing unit tests, some techniques have been proposed to automatically generate test assertions, with recent integration-based approaches considered state-of-the-art. Despite being promising, such integration-based approaches face several limitations, including reliance on lexical matching for assertion retrieval and a limited training corpus for assertion generation. This paper proposes a novel retrieval-augmented deep assertion generation approach, namely RetriGen, based on a hybrid retriever and a pre-trained language model (PLM)-based generator. Given a focal-test, RetriGen first builds a hybrid assertion retriever to search for the most relevant Test-Assert Pair from external codebases. The retrieval process considers lexical similarity and semantical similarity via a token-based and an embedding-based retriever, respectively. RetriGen then treats assertion generation as a sequence-to-sequence task and designs a PLM-based assertion generator to predict a correct assertion. We conduct extensive experiments to evaluate RetriGen against six state-of-the-art approaches across two large-scale datasets and two metrics. The results demonstrate that RetriGen achieves 57.66% accuracy and 73.24% CodeBLEU, outperforming all baselines with average improvements of 50.66% and 14.14%, respectively.
format Preprint
id arxiv_https___arxiv_org_abs_2502_16071
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Improving Deep Assertion Generation via Fine-Tuning Retrieval-Augmented Pre-trained Language Models
Zhang, Quanjun
Fang, Chunrong
Zheng, Yi
Zhang, Yaxin
Zhao, Yuan
Huang, Rubing
Zhou, Jianyi
Yang, Yun
Zheng, Tao
Chen, Zhenyu
Software Engineering
Unit testing validates the correctness of the units of the software system under test and serves as the cornerstone in improving software quality and reliability. To reduce manual efforts in writing unit tests, some techniques have been proposed to automatically generate test assertions, with recent integration-based approaches considered state-of-the-art. Despite being promising, such integration-based approaches face several limitations, including reliance on lexical matching for assertion retrieval and a limited training corpus for assertion generation. This paper proposes a novel retrieval-augmented deep assertion generation approach, namely RetriGen, based on a hybrid retriever and a pre-trained language model (PLM)-based generator. Given a focal-test, RetriGen first builds a hybrid assertion retriever to search for the most relevant Test-Assert Pair from external codebases. The retrieval process considers lexical similarity and semantical similarity via a token-based and an embedding-based retriever, respectively. RetriGen then treats assertion generation as a sequence-to-sequence task and designs a PLM-based assertion generator to predict a correct assertion. We conduct extensive experiments to evaluate RetriGen against six state-of-the-art approaches across two large-scale datasets and two metrics. The results demonstrate that RetriGen achieves 57.66% accuracy and 73.24% CodeBLEU, outperforming all baselines with average improvements of 50.66% and 14.14%, respectively.
title Improving Deep Assertion Generation via Fine-Tuning Retrieval-Augmented Pre-trained Language Models
topic Software Engineering
url https://arxiv.org/abs/2502.16071