Skip to main navigation Skip to search Skip to main content

Improving LLM-Driven Test Generation by Learning from Mocking Information

  • Jamie Lee
  • , Flynn Teh
  • , Hengcheng Zhu
  • , Mengzhen Li
  • , Mattia Fazzini
  • , Valerio Terragni

Research output: Chapter in Book/Report/Conference proceeding › Conference contribution

Abstract

Large Language Models (LLMs) have recently shown strong potential for automated unit test generation. This has motivated us to investigate whether developer-defined test doubles (commonly referred to as mocks) available in existing test suites can be leveraged to improve LLM-driven test generation. To this end, we propose MOCKMILL, an LLM-based technique and tool that generates test cases by exploiting mocking information automatically extracted from developer-written tests. MOCKMILL targets components that are replaced by test doubles in existing tests and uses the encoded stubbings and interaction expectations to guide test generation, combined with an iterative generation-and-repair process to ensure executable tests. We evaluated MOCKMILL on 10 open-source classes from six JAVA projects using four LLMs, and compared the generated tests with existing project tests and tests produced by baseline approaches. The results show that MOCKMILL's tests cover lines of code and kill mutants that existing tests and baseline-generated tests miss. Overall, our findings provide preliminary evidence that leveraging mocking information is a complementary and effective way to enhance LLM-based test generation.

Original languageEnglish (US)
Title of host publicationProceedings - 2026 IEEE International Conference on Software Testing, Verification and Validation Workshops, ICSTW 2026
PublisherInstitute of Electrical and Electronics Engineers Inc.
Pages1-8
Number of pages8
ISBN (Electronic)9798319546913
DOIs
StatePublished - 2026
Event2026 IEEE International Conference on Software Testing, Verification and Validation Workshops, ICSTW 2026 - Daejeon, Korea, Republic of
Duration: May 18 2026 → May 22 2026

Publication series

NameProceedings - 2026 IEEE International Conference on Software Testing, Verification and Validation Workshops, ICSTW 2026

Conference

Conference2026 IEEE International Conference on Software Testing, Verification and Validation Workshops, ICSTW 2026
Country/TerritoryKorea, Republic of
CityDaejeon
Period5/18/26 → 5/22/26

Bibliographical note

Publisher Copyright:
© 2026 IEEE.

Keywords

  • LLMs
  • Mocking
  • Test Doubles
  • Test Generation

Fingerprint

Dive into the research topics of 'Improving LLM-Driven Test Generation by Learning from Mocking Information'. Together they form a unique fingerprint.

Cite this