ensure-test-coverage

Review and create pytest test coverage for Inspect AI evaluations.

657|419|Updated Oct 2, 2024
One-click install
npx skills add https://github.com/UKGovernmentBEIS/inspect_evals --skill ensure-test-coverage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ensure-test-coverage
Source: https://github.com/UKGovernmentBEIS/inspect_evals/tree/main/.claude/skills/ensure-test-coverage
Command: npx skills add https://github.com/UKGovernmentBEIS/inspect_evals --skill ensure-test-coverage

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Evaluations in the inspect_evals repository often ship with missing or shallow tests, causing autolint CI failures and undetected regressions in scorers, solvers, tools, and dataset loaders. This Skill systematically audits a single evaluation's test coverage and creates the missing tests.

Core Features & Use Cases

  • Component Discovery: Scans eval source code for @task, @solver, @scorer, @tool functions, dataset loaders, and sandbox usage to build a complete testable-component inventory.
  • Coverage Measurement: Runs autolint checks and pytest-cov with --runslow to report per-file line coverage and classify missed lines as testable logic, LLM/sandbox-only code, or defensive guards.
  • Test Quality Review: Detects shallow tests such as isinstance-only scorer checks, fabricated dataset examples, missing pytest markers, and untested error paths.
  • Test Creation: Generates tests following repository conventions using templates for E2E, scorer, tool, sandbox, dataset, and HuggingFace validation patterns.
  • Use Case: A contributor submitting a new eval runs this Skill to find that their custom scorer lacks CORRECT/INCORRECT assertions and their E2E test is missing the @pytest.mark.dataset_download marker, then has both fixed before opening the PR.

Quick Start

Ask the AI to check and ensure test coverage for the gpqa evaluation, creating any missing tests.

Frequently Asked Questions about ensure-test-coverage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check test coverage for an inspect_evals evaluation?

Run the autolint tool with uv run python tools/run_autolint.py <eval_name> for structural checks, then run pytest with --cov=src/inspect_evals/<eval_name> --cov-report=term-missing --runslow for line-level coverage. This Skill automates both steps and interprets the results.

How do I write tests for a custom Inspect AI scorer?

Build a TaskState with a mockllm model, set state.output with ModelOutput.from_content, call the scorer with a Target, and assert the score value is CORRECT or INCORRECT. Parametrize inputs instead of writing near-duplicate test functions.

Should I test thin solver wrappers around react() in Inspect AI?

No. Solvers that only assemble Inspect built-ins like react() or chain() need at most an isinstance type check, and reviewers explicitly reject deeper tests of their internals. Only solvers with custom branching logic require behavioral tests.

How do I test sandbox-based tools that use Docker in pytest?

Use the shared utilities in tests/utils/sandbox_tools.py: create_sandbox_tool_task builds a minimal Task with your compose.yaml, and assert_sandbox_test_passed verifies the result. Mark these tests with @pytest.mark.docker and @pytest.mark.slow with the observed duration.

When should I not use this test coverage skill?

Do not use it to fix a specific failing CI test; that belongs to a CI maintenance workflow. It is designed for reviewing or creating an evaluation's overall test suite, not debugging individual test failures.

Why do record_to_sample tests need real dataset examples?

Tests using actual records from the dataset serve as both verification and documentation of the data schema. Fabricated examples can drift from the real dataset structure and miss parsing bugs that real records would expose.