Improving LLM-Driven Test Generation by Learning from Mocking Information

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Lee, Jamie, Teh, Flynn, Zhu, Hengcheng, Li, Mengzhen, Fazzini, Mattia, Terragni, Valerio
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917425735270400
author Lee, Jamie
Teh, Flynn
Zhu, Hengcheng
Li, Mengzhen
Fazzini, Mattia
Terragni, Valerio
author_facet Lee, Jamie
Teh, Flynn
Zhu, Hengcheng
Li, Mengzhen
Fazzini, Mattia
Terragni, Valerio
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2604_19315
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Improving LLM-Driven Test Generation by Learning from Mocking Information
Lee, Jamie
Teh, Flynn
Zhu, Hengcheng
Li, Mengzhen
Fazzini, Mattia
Terragni, Valerio
Software Engineering
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.
title Improving LLM-Driven Test Generation by Learning from Mocking Information
topic Software Engineering
url https://arxiv.org/abs/2604.19315