Authors’ overview
Retrieval-Augmented Generation (RAG)-based systemsFor brevity, RAG-based systems are referred to as RAG systems throughout this paper. are increasingly deployed in high-stakes settings where correct behaviour depends not only on the language model but also on the retrieval component that selects external documents at inference time. While existing RAG evaluation metrics assess retrieval and generation quality on a per-query basis, typically relying on query-level test oracles such as reference answers or relevance annotations, they provide limited insight into whether a test suite adequately exercises the retrieval behaviour of the system as a whole. In this paper, we introduce Chunk Coverage (CC), an oracle-independent test adequacy criterion for testing the retrieval component of RAG systems. CC measures the fraction of corpus chunks that are retrieved at least once across a test suite, providing a structural view of which parts of the retrieval space have been exercised. We further show how CC can be used to guide test selection and generation by prioritising queries that expand coverage of previously unexercised retrieval regions. We evaluate CC on clinical and financial RAG system scenarios. CC-guided testing reaches 50% of attainable coverage 1.7x faster than random selection and 4.2x faster than redundancy-biased strategies. Moreover, CC improves fault detection effectiveness (APFD) by 10% to 25% over random, indicating earlier discovery of distinct retrieval faults. These results show that CC captures retrieval diversity relevant to effective testing without requiring test oracles.
Introduction
Large Language Models (LLMs) are increasingly deployed as components of complex software systems, particularly in domains where decisions are safety-critical, regulated, or high-stakes. In such settings, developers are not merely interested in average model performance, but in gaining confidence that the system behaves as intended across the situations it may encounter. As with any such system, systematic testing is therefore essential. At the same time, the increasing adoption of Retrieval-Augmented Generation (RAG) as an architectural pattern in LLM systems introduces additional challenges for testing. RAG refers to a class of systems in which responses are generated based on information retrieved from an external document corpus at inference time. While RAG is most commonly instantiated in combination with LLMs, the retrieval component itself is conceptually independent of any particular generator.
In a typical RAG-based LLM system, test queries22 2 Throughout the paper, we use the terms query, test, and test query interchangeably to refer to the user-provided input that forms part of the prompt (e.g., within a prompt template) and triggers the RAG-based LLM system’s response. and corpus documents are embedded into a shared vector space, and a retriever selects a small set of documents that are incorporated into the prompt provided to the LLM. By grounding generation in an explicit document collection rather than relying solely on parametric knowledge acquired during training, such systems can operate over proprietary, dynamic, or domain-specific information sources, including internal technical documentation, scientific archives, legal texts, or organisational knowledge bases. In these deployments, correct system behaviour increasingly depends on which documents are retrieved, rather than on the LLM alone.
This architectural separation fundamentally changes what it means to test an RAG-based LLM system. Under a fixed configuration, retrieval behaviour is determined by the embedding model that maps queries and corpus chunks into a shared vector space, together with the vector database and its retrieval policy. These components jointly determine which parts of the corpus are accessible to the system at inference time. If relevant information is not retrieved, the LLM cannot compensate, regardless of its generative capabilities. Testing an RAG-based LLM system, therefore, necessarily entails testing its retrieval behaviour, not just the quality of generated outputs.
Despite this, the testing of RAG systems is still predominantly framed as an evaluation problem. Existing RAG evaluation metrics assess properties such as retrieval relevance, answer faithfulness, and grounding for individual query–response pairs, often relying on an auxiliary LLM as a proxy judge. These metrics are valuable for benchmarking and comparing configurations, but they answer a different question: how well does the system perform on a given query? They do not address a testing-native concern: does a test suite adequately exercise the retrieval behaviour of the system as a whole? From a software testing perspective, this distinction is critical. A test suite may achieve strong average evaluation scores while repeatedly retrieving the same small subset of popular documents, leaving large portions of the corpus effectively untested. Such blind spots are problematic when validating retrieval configurations prior to deployment, particularly in high-stakes settings where previously unseen retrieval behaviour may surface only after release.
Evaluation Metrics for RAG Systems
The evaluation of RAG systems has predominantly focused on assessing the quality of retrieved context and generated responses at the level of individual queries. Existing RAG evaluation metrics are primarily designed for performance assessment and benchmarking, rather than for analysing the adequacy of a test set (i.e., a collection of queries) or guiding test generation.
A prominent line of work proposes automated, reference-free evaluation metrics that approximate human judgements using LLMs. RAGAS introduces a suite of such metrics that decompose RAG evaluation into multiple dimensions, spanning both retrieval and generation. At the retrieval level, metrics such as Context Precision and Context Relevance assess how well the retrieved chunks align with the information needs expressed by a query. At the generation level, metrics including Response Relevancy, Faithfulness, and Response Groundedness evaluate whether the generated answer addresses the query and whether its claims are supported by the retrieved context. These metrics are computed independently for each query–response pair and are typically aggregated across a dataset to obtain overall performance scores.
Illustrative example
Similar evaluation goals are pursued by ARES, which proposes an automated framework for assessing RAG systems by judging the correctness and grounding of generated answers with respect to retrieved documents. ARES focuses on identifying unsupported or hallucinated claims by comparing generated responses against retrieved evidence, again relying on LLM-based judgements in the absence of explicit ground truth annotations.
While these metrics are well-suited for performance evaluation and system comparison, they provide limited insight into how a collection of tests collectively exercises the retrieval behaviour of a RAG system. Moreover, due to the common absence of ground-truth relevance and grounding annotations, existing metrics typically rely on an LLM-as-a-judge to approximate human assessments, which introduces additional subjectivity and uncertainty into the evaluation. Conceptually, these metrics are defined at the level of individual query–response pairs and are primarily intended to be averaged across a dataset, rather than to characterise properties of the query set itself. For instance, consider a RAG system deployed over hundreds of pages of internal technical documentation or regulatory reports. In such settings, developers must validate not only that individual queries retrieve relevant context, but also that the test suite as a whole exercises the retriever across the corpus, rather than repeatedly retrieving the same small subset of frequently accessed documents while leaving large portions of the corpus untested. This motivates the need for test adequacy metrics that characterise how thoroughly a RAG system’s retrieval behaviour is exercised by a test set, independently of per-query retrieval quality or answer correctness.
Interpretation and Applicability of Chunk Coverage
From a software testing perspective, CC plays a role analogous to code coverage in traditional programs. It abstracts away from output correctness and does not aim to compare alternative retrieval implementations or configurations. Instead, CC characterises whether the behavioural space of a fixed retrieval configuration has been sufficiently exercised by a test suite, thereby isolating the retriever as an explicit test target and enabling focused, coverage-guided testing of RAG systems.
As with traditional code coverage, not all uncovered elements necessarily warrant additional testing. In conventional programs, certain code regions, such as logging statements, may be intentionally deprioritised or excluded from coverage goals, even though they contribute to the overall coverage metric. Similarly, in RAG systems, some document chunks may be out of scope for the intended task, contain auxiliary or boilerplate information, or be deliberately ignored by developers. CC makes such unexercised regions explicit, allowing developers to decide which portions of the retrieval space are worth further testing, rather than implying that full (100%) coverage is always desirable.
It is worth noting that CC itself makes no assumption about whether the LLM relies on the retrieved documents to produce correct answers. CC purely characterises the behaviour of the retrieval component by measuring which parts of the document corpus are exercised by a test suite. Nevertheless, CC is most informative in RAG settings where the external document corpus constitutes a necessary source of task-relevant information. In open-knowledge tasks, where an LLM can often answer queries correctly without relying on retrieved documents, low coverage does not necessarily indicate inadequate testing, and full coverage is neither required nor expected. In such settings, CC should therefore be interpreted as a characterisation of retriever behaviour rather than as a measure of test adequacy. Accordingly, in our experiments, we focus on realistic deployment scenarios in which retrieval is essential for correct system behaviour, and CC can serve as a meaningful adequacy criterion.
Test Generation with Chunk Coverage
Based on the updated coverage information, the algorithm identifies chunks that have not yet been retrieved (Line 15). These uncovered chunks correspond to under-exercised regions of the retrieval space induced by the embedding model and vector database. For each uncovered chunk, the algorithm generates one or more new test queries with the explicit goal of retrieving that chunk (Lines 16–17). One possible instantiation of this step is to employ an auxiliary LLM that takes the content of an uncovered chunk as input and synthesises queries intended to retrieve it. The newly generated queries are added to the test suite (Line 18), and the process iterates.
This feedback-directed loop continues until the testing budget is exhausted or the target coverage threshold is reached (Lines 12–13). Importantly, CC-guided test generation relies solely on observable retrieval behaviour and does not require ground-truth relevance annotations or expected answers. As a result, it remains applicable in settings where defining precise test oracles is difficult or infeasible.
From a software testing perspective, this process mirrors coverage-guided testing in traditional software systems, where execution feedback is used to steer test generation towards untested program regions. In the context of RAG systems, CC provides an analogous feedback signal at the level of retrieval behaviour, enabling systematic and targeted exploration of the retriever independently of downstream generation quality.
Evaluation Scenarios
We consider three evaluation scenarios that differ in how test suites are incrementally constructed from a given pool of queries. First, in the coverage-guided (i.e., CC-guided) scenario, test queries are generated/selected to maximise incremental CC. At each step, queries that retrieve previously unexercised chunks are prioritised, with the explicit goal of systematically expanding coverage of the induced retrieval space. Second, the overlap-biased scenario represents a worst case from the perspective of CC. Test queries are selected to maximise overlap with already exercised retrieval behaviour, prioritising queries whose retrieved chunk sets strongly intersect with those observed so far. This deliberately limits exploration of new retrieval regions and serves as a conservative baseline. Third, in the random scenario, test queries are selected uniformly at random from the available pool, without regard to coverage or overlap. This reflects common practice in the absence of explicit adequacy criteria.
We note that we do not use entropy or the Gini coefficient as guidance signals because they are aggregate suite-level statistics rather than actionable per-query criteria: unlike CC, neither identifies which chunks remain untested. Turning them into selection strategies would require designing new greedy techniques and recomputing the suite-level retrieval distribution for every candidate at each step; moreover, both metrics can change non-monotonically as tests are added and thus provide neither a coverage target nor a stopping condition.
All three scenarios operate on the same underlying query pool and differ only in the query selection strategy, allowing us to isolate the effect of coverage guidance. The way in which the initial pool of test queries is obtained differs across datasets and is discussed next.
Relation to Testing Effectiveness (RQ3)
For MIMIC-IV, one exception occurs for response groundedness, where the random strategy slightly outperforms the coverage-guided strategy when test queries are generated using GPT-4o-mini. Since test queries for MIMIC-IV are obtained through LLM-assisted generation rather than from an existing, curated query set, the effectiveness of coverage-guided selection is bounded by the ability of the generation model to produce queries that meaningfully target distinct retrieval behaviour. To assess whether this effect is specific to the choice of generation model, we repeated the MIMIC-IV experiment using a stronger generator (GPT-5-mini) for test generation. In this setting, coverage-guided selection consistently outperforms random selection across all evaluation metrics, including response groundedness. This additional result suggests that the earlier exception can be attributable to limitations of the test generation model rather than to CC itself. We include the full results of this supplementary experiment in the online artefact (see Section Data Availability).
Overall, these results show that CC is closely aligned with testing effectiveness. By prioritising queries that exercise previously unvisited retrieval behaviour, the coverage-guided strategy advances fault discovery to earlier stages of testing. In contrast, strategies that favour redundant retrieval behaviour delay exposure of new failure modes. Because RQ3 includes LLM-output failures (Faithfulness, Response Relevancy, and Response Groundedness), the APFD gains indirectly link broader retrieval coverage to diverse output failures, but CC neither measures nor guarantees output correctness. A causal analysis remains future work.
Test Adequacy and Coverage Criteria
Test adequacy criteria have long played a central role in software testing, providing a principled basis for assessing whether a test suite sufficiently exercises a system under test. In traditional software, structural coverage metrics such as statement, branch, and path coverage approximate the extent to which program behaviour has been exercised, independently of output correctness. These metrics do not guarantee the absence of faults, but they provide actionable feedback for systematically improving test suites. In contrast, mutation testing assesses adequacy by measuring a test suite’s ability to detect injected faults through behavioural differences between the original program and its mutants, even when an explicit oracle for the original output is unavailable.
As Machine Learning (ML) systems gained prominence, several works extended the notion of coverage beyond control-flow structures to model-internal representations. DeepXplore and DeepGauge propose adequacy criteria based on neuron activations, aiming to quantify how thoroughly a deep neural network is exercised by a test set. Surprise Adequacy further characterises adequacy in terms of the novelty of test inputs with respect to the model’s training distribution, capturing how far test executions deviate from previously observed behaviours. Collectively, these approaches move beyond output accuracy as the sole evaluation criterion and instead emphasise behavioural exploration, in line with the role of coverage in traditional software testing.
Testing and Evaluation of LLMs
Although CC does not rely on LLMs and exclusively targets the retrieval component of RAG systems, LLMs remain a central element in most practical RAG deployments. We therefore briefly relate our work to prior research on testing and evaluating LLMs in order to situate CC within the broader landscape of testing methodologies for language-based systems. Recent work on LLM evaluation has examined a wide range of failure modes, including robustness through behavioural and adversarial testing, as well as bias and fairness using targeted benchmarks and audit-style evaluations. Other studies have focused on hallucination and factuality, particularly in knowledge-intensive and open-domain settings. These approaches typically assess models using per-input performance metrics or behavioural probes, which are often aggregated over curated benchmark datasets. While effective at revealing specific weaknesses, such evaluations do not provide explicit notions of test adequacy at the level of a test suite. Coverage-oriented perspectives have begun to emerge for language models. Frameworks such as CheckList organise tests around linguistic capabilities, and adaptive testing approaches iteratively generate tests based on observed failures. These works promote a coverage-oriented mindset but remain centred on the language model itself and do not account for systems whose behaviour is shaped by external retrieval components.
In contrast to these lines of work, CC targets the retrieval behaviour of RAG systems. Such behaviour is neither captured by traditional code coverage nor by model-internal coverage metrics. Rather than characterising how a model processes inputs internally, CC characterises how a test suite exercises the externally induced behaviour space defined by the document corpus, the embedding model, and the retrieval configuration.
Conclusion
We presented Chunk Coverage (CC) as a test adequacy criterion for the retrieval component of RAG systems. CC exposes retrieval behaviour at the level of a test suite, independently of per-query correctness, and provides a practical signal for guiding test generation/selection without requiring test oracles. Across clinical and financial RAG scenarios, CC-guided testing systematically explores a larger portion of the retrieval space and detects distinct retrieval faults earlier than random or redundancy-biased strategies. These results show that retrieval diversity, as captured by CC, is directly linked to testing effectiveness. By complementing existing per-query RAG evaluation metrics with a suite-level perspective, CC offers a principled foundation for systematic testing and validation of retrieval-centric LLM systems prior to deployment.


