AugmenTest: Enhancing Tests with LLM-Driven Oracles
Shaker Mahmud Khandaker, Fitsum Kifetew, Davide Prandi, Angelo Susi
TL;DR
AugmenTest introduces a framework to infer correct test oracles by leveraging LLMs trained on documentation and comments rather than code, addressing a core challenge in automated test generation. It evaluates four prompt variants (Simple, Extended, RAG, RAG SP) and demonstrates that context-rich prompts, particularly Extended Prompt with GPT-4o, reliably generate correct assertions better than the TOGA baseline, while retrieval-augmented generation yields no clear gains. The two-phase approach—metadata extraction followed by LLM-driven assertion generation—supports a flexible, model-agnostic workflow, though results with RAG and some local models reveal areas for improvement in data integration and semantic validation. Overall, the work shows promising potential for LLM-driven, context-aware test oracle inference, with clear directions for future assurance, ranking, and cross-language applicability.
Abstract
Automated test generation is crucial for ensuring the reliability and robustness of software applications while at the same time reducing the effort needed. While significant progress has been made in test generation research, generating valid test oracles still remains an open problem. To address this challenge, we present AugmenTest, an approach leveraging Large Language Models (LLMs) to infer correct test oracles based on available documentation of the software under test. Unlike most existing methods that rely on code, AugmenTest utilizes the semantic capabilities of LLMs to infer the intended behavior of a method from documentation and developer comments, without looking at the code. AugmenTest includes four variants: Simple Prompt, Extended Prompt, RAG with a generic prompt (without the context of class or method under test), and RAG with Simple Prompt, each offering different levels of contextual information to the LLMs. To evaluate our work, we selected 142 Java classes and generated multiple mutants for each. We then generated tests from these mutants, focusing only on tests that passed on the mutant but failed on the original class, to ensure that the tests effectively captured bugs. This resulted in 203 unique tests with distinct bugs, which were then used to evaluate AugmenTest. Results show that in the most conservative scenario, AugmenTest's Extended Prompt consistently outperformed the Simple Prompt, achieving a success rate of 30\% for generating correct assertions. In comparison, the state-of-the-art TOGA approach achieved 8.2\%. Contrary to our expectations, the RAG-based approaches did not lead to improvements, with performance of 18.2\% success rate for the most conservative scenario.
