Rug: Turbo Llm for Rust Unit Test Generation

Unit testing improves software quality by evaluating isolated sections of the program. This approach alleviates the need for comprehensive program-wide testing and confines the potential error scope within the software. However, unit test development is time-consuming, requiring developers to create...

Full description

Saved in:
Bibliographic Details
Published inProceedings / International Conference on Software Engineering pp. 2983 - 2995
Main Authors Cheng, Xiang, Sang, Fan, Zhai, Yizhuo, Zhang, Xiaokuan, Kim, Taesoo
Format Conference Proceeding
LanguageEnglish
Published IEEE 26.04.2025
Subjects
Online AccessGet full text
ISSN1558-1225
DOI10.1109/ICSE55347.2025.00097

Cover

Loading…
Abstract Unit testing improves software quality by evaluating isolated sections of the program. This approach alleviates the need for comprehensive program-wide testing and confines the potential error scope within the software. However, unit test development is time-consuming, requiring developers to create appropriate test contexts and determine input values to cover different code regions. This problem is particularly pronounced in Rust due to its intricate type system, making traditional unit test generation tools ineffective in Rust projects. Recently, large language models (LLMs) have demonstrated their proficiency in understanding programming language and completing software engineering tasks. However, merely prompting LLMs with a basic prompt like "generate unit test for the following source code" often results in code with compilation errors. In addition, LLM-generated unit tests often have limited test coverage. To bridge this gap and harness the capabilities of LLM, we design and implement RUG, an end-to-end solution to automatically generate the unit test for Rust projects. To help LLM's generated test pass Rust strict compilation checks, RUG designs a semantic-aware bottom-up approach to divide the context construction problem into dependent sub-problems. It solves these sub-problems sequentially using an LLM and merges them to a complete context. To increase test coverage, RUG integrates coverage-guided fuzzing with LLM to prepare fuzzing harnesses. Applying RUG on 17 real-world Rust programs (average 24,937 \text{LoC} ), we show that RUG can achieve a high code coverage, up to \mathbf{7 1. 3 7 \%} , closely comparable to human effort (\mathbf{7 3. 1 8 \%}) . We submitted 113 unit tests generated by RUG covering the new code: 53 of them have been accepted, 17 rejected, and 43 are pending for review.
AbstractList Unit testing improves software quality by evaluating isolated sections of the program. This approach alleviates the need for comprehensive program-wide testing and confines the potential error scope within the software. However, unit test development is time-consuming, requiring developers to create appropriate test contexts and determine input values to cover different code regions. This problem is particularly pronounced in Rust due to its intricate type system, making traditional unit test generation tools ineffective in Rust projects. Recently, large language models (LLMs) have demonstrated their proficiency in understanding programming language and completing software engineering tasks. However, merely prompting LLMs with a basic prompt like "generate unit test for the following source code" often results in code with compilation errors. In addition, LLM-generated unit tests often have limited test coverage. To bridge this gap and harness the capabilities of LLM, we design and implement RUG, an end-to-end solution to automatically generate the unit test for Rust projects. To help LLM's generated test pass Rust strict compilation checks, RUG designs a semantic-aware bottom-up approach to divide the context construction problem into dependent sub-problems. It solves these sub-problems sequentially using an LLM and merges them to a complete context. To increase test coverage, RUG integrates coverage-guided fuzzing with LLM to prepare fuzzing harnesses. Applying RUG on 17 real-world Rust programs (average 24,937 \text{LoC} ), we show that RUG can achieve a high code coverage, up to \mathbf{7 1. 3 7 \%} , closely comparable to human effort (\mathbf{7 3. 1 8 \%}) . We submitted 113 unit tests generated by RUG covering the new code: 53 of them have been accepted, 17 rejected, and 43 are pending for review.
Author Cheng, Xiang
Zhang, Xiaokuan
Kim, Taesoo
Sang, Fan
Zhai, Yizhuo
Author_xml – sequence: 1
  givenname: Xiang
  surname: Cheng
  fullname: Cheng, Xiang
  email: cxworks@gatech.edu
  organization: Georgia Institute of Technology
– sequence: 2
  givenname: Fan
  surname: Sang
  fullname: Sang, Fan
  email: fsang@gatech.edu
  organization: Georgia Institute of Technology
– sequence: 3
  givenname: Yizhuo
  surname: Zhai
  fullname: Zhai, Yizhuo
  email: yzhai60@gatech.edu
  organization: Georgia Institute of Technology
– sequence: 4
  givenname: Xiaokuan
  surname: Zhang
  fullname: Zhang, Xiaokuan
  email: xiaokuan@gmu.edu
  organization: George Mason University
– sequence: 5
  givenname: Taesoo
  surname: Kim
  fullname: Kim, Taesoo
  email: taesoo@gatech.edu
  organization: Georgia Institute of Technology
BookMark eNotj81Kw0AURkdRsK19gy7mAUy885eZ605CrYWAUOO6zDR3JNImMkkWvr0BXX1ncTjwLdlN13fE2EZALgTg47583xqjtM0lSJMDANortkaLTilhwBQortlCGOMyIaW5Y8th-Jq1QiMu2MNh-nzi9ZRCz6vzhcc-8cM0jPyja0de00w76ij5se27e3Yb_Xmg9f-uWP2yrcvXrHrb7cvnKmtRjZm2_uQpQNSNECRO3qIMrrAN6RhIWykiErqAAZyKRdSglJINgZdRQnRqxTZ_2ZaIjt-pvfj0c5zfSrTKqV9S90QD
CODEN IEEPAD
ContentType Conference Proceeding
DBID 6IE
6IH
CBEJK
RIE
RIO
DOI 10.1109/ICSE55347.2025.00097
DatabaseName IEEE Electronic Library (IEL) Conference Proceedings
IEEE Proceedings Order Plan (POP) 1998-present by volume
IEEE Xplore All Conference Proceedings
IEEE Electronic Library (IEL)
IEEE Proceedings Order Plans (POP) 1998-present
DatabaseTitleList
Database_xml – sequence: 1
  dbid: RIE
  name: IEEE Electronic Library (IEL)
  url: https://proxy.k.utb.cz/login?url=https://ieeexplore.ieee.org/
  sourceTypes: Publisher
DeliveryMethod fulltext_linktorsrc
Discipline Computer Science
EISBN 9798331505691
EISSN 1558-1225
EndPage 2995
ExternalDocumentID 11029738
Genre orig-research
GrantInformation_xml – fundername: NSF
  grantid: CNS-1749711
  funderid: 10.13039/100000001
– fundername: ONR
  grantid: N00014-23-1-2095
  funderid: 10.13039/100000006
GroupedDBID -~X
.4S
.DC
29O
5VS
6IE
6IF
6IH
6IK
6IL
6IM
6IN
8US
AAJGR
AAWTH
ABLEC
ADZIZ
ALMA_UNASSIGNED_HOLDINGS
ARCSS
AVWKF
BEFXN
BFFAM
BGNUA
BKEBE
BPEOZ
CBEJK
CHZPO
EDO
FEDTE
I-F
IEGSK
IJVOP
IPLJI
M43
OCL
RIE
RIL
RIO
ID FETCH-LOGICAL-i93t-47acaeb0f4d11e1ca792b867de4fbe4721f9e98b9b083f6f403332de0a2f20f83
IEDL.DBID RIE
IngestDate Wed Aug 27 01:40:13 EDT 2025
IsPeerReviewed false
IsScholarly true
Language English
LinkModel DirectLink
MergedId FETCHMERGED-LOGICAL-i93t-47acaeb0f4d11e1ca792b867de4fbe4721f9e98b9b083f6f403332de0a2f20f83
PageCount 13
ParticipantIDs ieee_primary_11029738
PublicationCentury 2000
PublicationDate 2025-April-26
PublicationDateYYYYMMDD 2025-04-26
PublicationDate_xml – month: 04
  year: 2025
  text: 2025-April-26
  day: 26
PublicationDecade 2020
PublicationTitle Proceedings / International Conference on Software Engineering
PublicationTitleAbbrev ICSE
PublicationYear 2025
Publisher IEEE
Publisher_xml – name: IEEE
SSID ssj0006499
Score 2.3101003
Snippet Unit testing improves software quality by evaluating isolated sections of the program. This approach alleviates the need for comprehensive program-wide testing...
SourceID ieee
SourceType Publisher
StartPage 2983
SubjectTerms Codes
Fuzzing
Large language model
Large language models
Reviews
Rust
Scalability
Software engineering
Software quality
Source coding
Test pattern generators
Testing
Unit testing
Title Rug: Turbo Llm for Rust Unit Test Generation
URI https://ieeexplore.ieee.org/document/11029738
hasFullText 1
inHoldings 1
isFullTextHit
isPrint
link http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV1LSwMxEA62J0_1UfFNDh7dNptkk43X0lJFi9QVeivJZiKitlJ3L_56k91tFUHwFnLIgyHzzST5vkHoQutcepS0UdAaiTj1CYq2wLxBYkpAaqpFICffTcT4kd_MkllDVq-4MABQfT6DXmhWb_l2mZfhqqzvoSqUWkpbqOUzt5qstXG7wsfuDTcuJqp_PXgYJgnj0ueANNybVLpOPyqoVAAy6qDJeur638hLryxML__8pcr477XtoO43Vw_fb1BoF23BYg911sUacHN299HltHy6wlm5Mkt8-_qGfbCKp-VHgUPUiTMPDriWoA6W6qJsNMwG46gplRA9K1ZEXOpcgyGO2ziGONdSUZMKaYE7A9xneU6BSo0yPuJywnHCGKMWiKaOEpeyA9ReLBdwiLCSkCZAHWg_mncAqbBMSpuTILxmEnqEumHz8_daDGO-3vfxH_0naDsYIDzAUHGK2sWqhDOP44U5r-z3BehKm1w
linkProvider IEEE
linkToHtml http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV07T8MwED5BGWAqjyLeeGAkbWI7ccJatWqhrVAJUrfKjs8IAS0qycKvx07agpCQ2CwPfujk--5sf98BXEmZCYuS2nNaIx6nNkGRGpk1SEB9FJLKyJGTh6Oo98hvJ-FkSVYvuTCIWH4-w6Zrlm_5ep4V7qqsZaHKlVqKN2HLAn8YVHStteONbPS-ZMcFftLqtx86Yci4sFkgdTcnpbLTjxoqJYR06zBaTV79HHlpFrlqZp-_dBn_vbpdaHyz9cj9Gof2YANn-1BflWsgy9N7ANfj4umGpMVCzcng9Y3YcJWMi4-cuLiTpBYeSCVC7WzVgLTbSds9b1kswXtOWO5xITOJyjdcBwEGmRQJVXEkNHKjkNs8zySYxCpRNuYykeE-Y4xq9CU11DcxO4TabD7DIyCJwDhEalDa0awLiCPNhNCZ76TXVEiPoeE2P32v5DCmq32f_NF_Cdu9dDiYDvqju1PYccZwzzE0OoNavijw3KJ6ri5KW34BOBmepQ
openUrl ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fsummon.serialssolutions.com&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=proceeding&rft.title=Proceedings+%2F+International+Conference+on+Software+Engineering&rft.atitle=Rug%3A+Turbo+Llm+for+Rust+Unit+Test+Generation&rft.au=Cheng%2C+Xiang&rft.au=Sang%2C+Fan&rft.au=Zhai%2C+Yizhuo&rft.au=Zhang%2C+Xiaokuan&rft.date=2025-04-26&rft.pub=IEEE&rft.eissn=1558-1225&rft.spage=2983&rft.epage=2995&rft_id=info:doi/10.1109%2FICSE55347.2025.00097&rft.externalDocID=11029738