SEApr 21

Improving LLM-Driven Test Generation by Learning from Mocking Information

arXiv:2604.1931564.9Has Code
Predicted impact top 21% in SE · last 90 daysOriginality Incremental advance
AI Analysis

For software engineers, it improves automated test generation by leveraging existing test doubles, though the evaluation is limited to 10 classes.

MOCKMILL uses mocking information from existing test suites to guide LLM-based unit test generation, achieving higher line coverage and mutation killing than baseline approaches on 10 Java classes from 6 projects.

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.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes