Search papers, labs, and topics across Lattice.
MOCKMILL leverages mocking information from existing test suites to improve LLM-driven unit test generation by targeting components replaced by test doubles and using encoded stubbings and interaction expectations to guide test case creation. An iterative generation-and-repair process ensures the generated tests are executable. Experiments on 10 Java classes using four LLMs demonstrate that MOCKMILL generates tests that achieve higher code coverage and mutant killing rates compared to existing and baseline-generated tests.
LLMs generate better unit tests when they learn from existing test mocks, achieving higher code coverage and mutant killing rates.
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.