CovQValue for Curiosity-Driven Test Generation
- CovQValue is a curiosity-driven planning method that treats test generation as a sequential decision-making process using coverage maps to estimate branch reachability.
- It generates diverse multi-step test plans scored by combining immediate branch discovery with a future reachability term, overcoming limitations of greedy approaches.
- Empirical evaluations show CovQValue achieves up to 77% higher branch coverage on real Python modules compared to reactive test generation methods.
Searching arXiv for the CovQValue paper and closely related context papers to ground the article. CovQValue is a curiosity-driven planning method for iterative, LLM-based unit test generation for real Python code. It treats test generation as sequential decision-making in an unknown environment, uses a coverage map as a proxy probabilistic posterior over the program’s branch reachability structure, generates diverse multi-step test plans, and ranks them by an LLM-estimated curiosity Q-value that combines immediate branch discovery with future reachability. In the reported experiments, this planning-based formulation is designed to overcome “coverage corridors,” namely sequences of setup steps that each contribute zero new branch coverage individually, but collectively unlock access to deep logic (Amayuelas et al., 6 Apr 2026).
1. Definition and problem setting
CovQValue is introduced in a setting where an agent interacts with a target Python module or file in a real repository. The agent can inspect the source of , generate test scripts that import and call into , and execute those scripts in an instrumented environment that reports which branches were executed. The objective is to maximize cumulative branch coverage over a fixed execution budget , with branch coverage defined as the number or fraction of distinct control-flow branches in the target module that have been taken at least once.
The method is motivated by a limitation of existing LLM-based test generation tools such as CodaMosa, CoverUp, and TestForge. These systems typically optimize each step for immediate coverage gain. The paper argues that this greedy regime plateaus on code with “coverage corridors,” because any single setup step in such a corridor appears uninformative in isolation. The examples given include multi-step initialization sequences in frameworks, validation gates, and import chains and configuration requirements. In these regimes, a selector that always chooses the test predicted to maximize immediate coverage will not invest in a sequence of zero-gain steps and therefore will not reach the deep branches behind the corridor (Amayuelas et al., 6 Apr 2026).
The formal reframing is explicitly Bayesian. The unknown environment parameter is the program’s full branch reachability structure. At step , the agent takes an action , observes an outcome , and accumulates a history
The exploration objective is to maximize cumulative information gain about , approximated in this application by the total number of distinct branches discovered.
2. Bayesian exploration formulation
The method maps the components of optimal Bayesian exploration onto iterative test generation. In the paper’s formulation, the prior 0 corresponds to initially having no observed branches, the history is the sequence of test-plan and coverage-result pairs, and the posterior exploration state 1 is approximated by a coverage map 2. The action is a test plan, defined as a sequence of 3 scripts, and the observation is the set of branches hit by executing that plan.
The theoretical quantities are written as
4
for expected information gain and
5
with 6, for the curiosity Q-value. CovQValue does not compute this posterior or mutual information explicitly. Instead, it uses a deterministic coverage map as a sufficient statistic for exploration and relies on the LLM to perform implicit Bayesian reasoning conditioned on that map (Amayuelas et al., 6 Apr 2026).
The coverage map is cumulative: 7 and the implementation updates it after each execution via
8
In prompts, the map is serialized as structured text. The examples in the paper include fields for total branches discovered so far, the number of new branches from the last step, average gain per step, a ranked list of the most informative tests with branch counts, and warnings when coverage has stagnated for several steps. This makes the exploration state legible to the model without constructing an explicit probabilistic posterior.
A recurrent misconception is to read this formulation as conventional Bayesian RL with an explicit posterior update. The paper states the opposite: the precise distribution 9 is never computed, and the Q-values are heuristic plan-ranking signals rather than Bellman-consistent value estimates.
3. Algorithmic structure
CovQValue is an iterative open-loop planner. At each planning round it maintains a coverage map 0 and a history 1, generates 2 diverse candidate multi-step plans, asks the LLM to estimate for each plan an immediate expected gain 3 and a future reachability term 4, computes
5
and executes the plan with the highest 6, step by step, updating 7 and 8 after each script execution.
Using the notation given in the paper, the plan set is
9
where 0 is the script at step 1 of plan 2. The formal loop initializes 3 and 4, generates 5 plans with diversity hints, scores them by curiosity Q-value, selects
6
and then executes 7 sequentially until the total execution budget is exhausted (Amayuelas et al., 6 Apr 2026).
The main experiments use 8 steps per plan and 9 plans per round. With total budget 0 scripts, this yields 1 rounds of planning. The plan structure is explicitly intended to support corridors: step 2 can be basic setup, step 3 can build on that setup, and step 4 can probe deeper logic or edge cases that only became reachable after the earlier steps.
The scoring rule is deliberately simple. For each plan, the LLM is asked for two numbers: immediate gain, interpreted as the number of total new branches expected from the plan, and future value, interpreted as the number of additional branches that become reachable by future tests after this plan. The absolute scale is not the important quantity; only the induced ranking over candidate plans matters.
4. Prompting, execution loop, and implementation details
Every generation and scoring prompt contains three pieces of state: truncated source code of the module, the current coverage map, and a short test history listing prior tests and their branch contributions. For plan generation, the prompt asks for “a sequence of 3 test scripts that TOGETHER will reach UNCOVERED code paths” and includes directional guidance such as “MAIN functionality,” “ERROR HANDLING,” or “INTERACTIONS.” These directives are used as diversity hints so that the 5 plans per round explore different parts of the reachable behavior.
For plan scoring, the prompt presents the same module context and coverage map together with a single proposed plan and asks the model to output two integers in the format “immediate, future.” The orchestrator then computes the scalar score 6. In the main experiments, 7, and ablations consider 8 (Amayuelas et al., 6 Apr 2026).
The model configuration also differs by subtask. Generation uses temperature 9 to encourage diversity and exploratory tests. Scoring and selection use temperature 0 to encourage more stable rankings. The evaluated LLMs are Gemini 3 Flash, GPT‑5.4 Mini, and Mistral Large 3, and each model is used both for generation and for scoring within a given run.
The paper positions the coverage map as the key feedback channel. At the beginning it may contain only “Branches discovered: 0.” After several rounds it may report recent marginal gain, average gain per step, and the most informative tests. After stagnation it may add an explicit warning that “Coverage has stagnated for 3 steps” and suggest that a fundamentally different approach may be needed. This closed-loop conditioning is a major distinction from single-step prompting regimes.
5. Empirical evaluation
The evaluation uses two benchmarks. TestGenEval Lite is derived from TestGenEval, built on SWE-Bench, and contains 1 file-level targets after excluding scikit-learn because of C-extension build issues. RepoExploreBench is introduced specifically for iterative exploration and corridor scenarios; it contains 2 modules from 3 popular PyPI packages, around 4K lines of Python total, and selects modules with at least 5 lines while avoiding tests-only and vendored or compat layers. All methods are evaluated under the same budget 6 scripts (Amayuelas et al., 6 Apr 2026).
The comparison set consists of Random, Greedy, CovGreedy, and CovQValue. Random generates 7 tests and selects one uniformly at random. Greedy uses the same generation pattern but asks the LLM to choose the candidate “most likely to cover new code paths,” based only on the code and without the coverage map. CovGreedy augments generation with the coverage map and instructs the LLM to target undiscovered branches, but still selects randomly among the candidates. CovQValue uses 8 plans of 9 scripts, includes the coverage map, applies diversity hints, and chooses the plan with the highest estimated curiosity Q-value.
The main quantitative result is that CovQValue outperforms greedy selection on both benchmarks. On RepoExploreBench, the reported gains over Greedy are 0 to 1 branches, corresponding to approximately 2–3 higher coverage. On TestGenEval Lite, the reported gains are 4 to 5 branches, corresponding to approximately 6–7 higher coverage. The win rate over Greedy is 8–9 across the three models, with paired 0-tests reported as 1 in all settings and Cohen’s 2 in the range 3–4 (Amayuelas et al., 6 Apr 2026).
The coverage curves show a characteristic pattern. Random and Greedy plateau after approximately five steps. CovGreedy continues to climb because of coverage-map guidance. CovQValue climbs faster and often exhibits sharp jumps when traversing corridors. The case studies are consistent with this interpretation. In flask.app, Random and Greedy remain at 5 branches after 6 steps, whereas CovQValue reaches 7 branches by constructing the correct multi-step initialization sequence. In werkzeug.http, Greedy gets stuck at 8 branches, while CovQValue uses the coverage map to target parse_etags, parse_list_header, parse_dict_header, and then parse_options_header, dump_options_header, parse_cookie, and dump_cookie, producing jumps of 9 and 0 branches.
The ablations refine this picture. On RepoExploreBench with Gemini 3 Flash, coverage grows from about 1 branches at 2 to about 3 at 4, whereas Random stays near 5 even as 6 increases. With plan-length variation, longer plans provide additional gains beyond execution count alone. For the discount factor, the reported means are 7 branches for 8, 9 for 0, and 1 for 2. A component ablation attributes substantial gains independently to the coverage map, diversity hints, and Q-value scoring.
6. Limitations, positioning, and disambiguation
The paper identifies several limitations. The Q-value estimator is heuristic: the LLM provides 3 and 4 from its internal understanding, with no guarantee of calibration or Bellman consistency. The coverage map is only a proxy posterior and does not encode explicit uncertainty or reachability probabilities. The method also incurs extra computational overhead because each round requires multiple LLM calls for both plan generation and Q-value scoring. In addition, the planning horizon is limited, the approach depends on branch-coverage instrumentation and Dockerized environments, and performance is sensitive to the code-understanding and ranking quality of the underlying model (Amayuelas et al., 6 Apr 2026).
Within LLM-based test generation, CovQValue is positioned against reactive or greedy systems such as CodaMosa, CoverUp, TELPA, and TestForge. Its distinctive move is not merely the use of coverage feedback, but the combination of a structured coverage map, multi-step plans, and explicit valuation of future reachability. This suggests a shift from one-shot coverage chasing toward exploration policies that treat test generation as an intrinsically sequential process.
A separate and unrelated usage appears in convex geometry. In the provided material on “Covariograms generated by valuations,” the label “CovQValue” is used for the valuation–covariogram quantity
5
where 6 is a valuation on compact convex subsets of 7. In that setting, the object generalizes Matheron’s covariogram, admits a convolution representation in the plane, and is studied in connection with reconstruction of convex bodies from overlap profiles (Averkov et al., 2013). The shared name therefore does not indicate a shared domain: the 2026 CovQValue method concerns curiosity-driven planning for LLM test generation, whereas the 2013 usage concerns valuation-generated covariograms in convex and stochastic geometry.