Academic Journal

Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies.

Λεπτομέρειες βιβλιογραφικής εγγραφής
Τίτλος: Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies.
Συγγραφείς: Ferrer, Javier1 (AUTHOR) jferrer@uma.es, Chicano, Francisco1 (AUTHOR)
Πηγή: Expert Systems. Oct2026, Vol. 43 Issue 10, p1-21. 21p.
Θεματικοί όροι: *Mathematical optimization, Prompt engineering, Computer software testing
Περίληψη: While Large Language Models (LLMs) have demonstrated remarkable capabilities in code generation, their effectiveness in unit testing is often constrained by insufficient context regarding external dependencies. This limitation is particularly pronounced in industrial settings, where proprietary code remains opaque to the model. To address this challenge, we present a systematic empirical study of multiple strategies for context enrichment and optimization in LLM‐based unit test generation, conducted on seven diverse projects (three open‐source and four proprietary industrial systems), encompassing 261 distinct methods. By evaluating seven implementations (ranging from basic prompts to optimized context reduction strategies) across 10 independent runs, we analysed a total of 28,710 test suites. Our results demonstrate that combining prompt engineering with external dependency retrieval achieves an average branch coverage increase of 11.52 percentage points on industrial software over the baseline, with statistically significant improvements across all competing implementations. Beyond coverage, richer context substantially reduces generation‐repair iterations, cutting median execution time by 51.3% in industrial projects. We further show that reducing external dependencies to method signatures alone decreases input token consumption by up to 46.6% (25.4% in industrial projects) while fully preserving the coverage and efficiency gains of the complete retrieval approach. To confirm that these benefits are not tied to a specific model, we replicate the core comparison across three LLM backends from different families, obtaining a consistent, statistically significant coverage improvement on industrial code in every case. These findings establish this optimized context strategy as a cost‐effective solution for scalable, industrial‐grade automated test generation. [ABSTRACT FROM AUTHOR]
Copyright of Expert Systems is the property of Wiley-Blackwell and its content may not be copied or emailed to multiple sites without the copyright holder's express written permission. Additionally, content may not be used with any artificial intelligence tools or machine learning technologies. However, users may print, download, or email articles for individual use. This abstract may be abridged. No warranty is given about the accuracy of the copy. Users should refer to the original published version of the material for the full abstract. (Copyright applies to all Abstracts.)
Βάση Δεδομένων: Business Source Index
Περιγραφή
ISSN:02664720
DOI:10.1111/exsy.70401