Academic Journal
Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies.
| Title: | Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies. |
|---|---|
| Authors: | Ferrer, Javier1 (AUTHOR) jferrer@uma.es, Chicano, Francisco1 (AUTHOR) |
| Source: | Expert Systems. Oct2026, Vol. 43 Issue 10, p1-21. 21p. |
| Subject Terms: | *Mathematical optimization, Prompt engineering, Computer software testing |
| Abstract: | 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.) | |
| Database: | Business Source Index |
| FullText | Text: Availability: 0 CustomLinks: – Url: https://resolver.ebsco.com/c/fiv2js/result?sid=EBSCO:bsx&genre=article&issn=02664720&ISBN=&volume=43&issue=10&date=20261001&spage=1&pages=1-21&title=Expert Systems&atitle=Optimizing%20Context%20and%20Cost%20in%20LLM%E2%80%90Based%20Unit%20Test%20Generation%3A%20A%20Study%20on%20External%20Dependency%20Retrieval%20Strategies.&aulast=Ferrer%2C%20Javier&id=DOI:10.1111/exsy.70401 Name: Full Text Finder (for New FTF UI) (ns324271) Category: fullText Text: Full Text Finder MouseOverText: Full Text Finder |
|---|---|
| Header | DbId: bsx DbLabel: Business Source Index An: 197136948 RelevancyScore: 1418 AccessLevel: 6 PubType: Academic Journal PubTypeId: academicJournal PreciseRelevancyScore: 1417.99206542969 |
| IllustrationInfo | |
| Items | – Name: Title Label: Title Group: Ti Data: Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies. – Name: Author Label: Authors Group: Au Data: <searchLink fieldCode="AR" term="%22Ferrer%2C+Javier%22">Ferrer, Javier</searchLink><relatesTo>1</relatesTo> (AUTHOR)<i> jferrer@uma.es</i><br /><searchLink fieldCode="AR" term="%22Chicano%2C+Francisco%22">Chicano, Francisco</searchLink><relatesTo>1</relatesTo> (AUTHOR) – Name: TitleSource Label: Source Group: Src Data: <searchLink fieldCode="JN" term="%22Expert+Systems%22">Expert Systems</searchLink>. Oct2026, Vol. 43 Issue 10, p1-21. 21p. – Name: Subject Label: Subject Terms Group: Su Data: *<searchLink fieldCode="DE" term="%22Mathematical+optimization%22">Mathematical optimization</searchLink><br /><searchLink fieldCode="DE" term="%22Prompt+engineering%22">Prompt engineering</searchLink><br /><searchLink fieldCode="DE" term="%22Computer+software+testing%22">Computer software testing</searchLink> – Name: Abstract Label: Abstract Group: Ab Data: 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] – Name: AbstractSuppliedCopyright Label: Group: Ab Data: <i>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.</i> (Copyright applies to all Abstracts.) |
| PLink | https://search.ebscohost.com/login.aspx?direct=true&site=eds-live&db=bsx&AN=197136948 |
| RecordInfo | BibRecord: BibEntity: Identifiers: – Type: doi Value: 10.1111/exsy.70401 Languages: – Code: eng Text: English PhysicalDescription: Pagination: PageCount: 21 StartPage: 1 Subjects: – SubjectFull: Mathematical optimization Type: general – SubjectFull: Prompt engineering Type: general – SubjectFull: Computer software testing Type: general Titles: – TitleFull: Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies. Type: main BibRelationships: HasContributorRelationships: – PersonEntity: Name: NameFull: Ferrer, Javier – PersonEntity: Name: NameFull: Chicano, Francisco IsPartOfRelationships: – BibEntity: Dates: – D: 01 M: 10 Text: Oct2026 Type: published Y: 2026 Identifiers: – Type: issn-print Value: 02664720 Numbering: – Type: volume Value: 43 – Type: issue Value: 10 Titles: – TitleFull: Expert Systems Type: main |
| ResultId | 1 |