mcpField
W
write-rust-tests

write-rust-tests

github.com/redisearchTesting & quality6.2k64 installsUpdated today
Repository

About write-rust-tests

write-rust-tests is a skill for creating Rust tests in specified crates or files. It guides test selection around uncovered branches and existing coverage, following rust-tests-guidelines to avoid redundant cases.

Key features

  1. 01Accept crate or file paths
  2. 02Cover public APIs and edge cases
  3. 03Use coverage checks to find gaps
  4. 04Identify unique branches before each test
  5. 05Avoid redundant tests and trivial delegations

Use cases

  1. 01Add tests to a Rust crate or file
  2. 02Find uncovered behavior to test
  3. 03Review proposed tests for overlap
  4. 04Check edge cases and error paths

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/redisearch/redisearch --skill write-rust-tests

After installing, type/write-rust-testsin Claude Code to confirm it loaded.

Details

From the project README

Write Rust Tests

Write new Rust tests for Rust code.

Arguments

  • <path>: Path to the Rust crate or file.
  • <path 1> <path 2>: Multiple crate/file paths.

If a path doesn't include src/, assume it to be in the src/redisearch_rs directory. E.g. numeric_range_tree becomes src/redisearch_rs/numeric_range_tree. If a path points to a directory, consider all Rust files in that directory.

Guidelines

The generated tests must follow the guidelines outlined in /rust-tests-guidelines.

What to test

Ensure that all public APIs are tested thoroughly, including edge cases, error conditions and branches. Use /check-rust-coverage to determine which lines are not covered by tests.

Avoiding redundant tests

Before writing each test, explicitly identify which branch or code path it will cover that no existing test already covers. An uncovered line is not sufficient justification — ask why it is uncovered and whether it is reachable through an already-tested entry point.

Two tests are redundant if they exercise the same set of branches in the code under test. Differing only in input values that don't change control flow is not a distinct scenario.

Do not write standalone tests for:

  • Trivial trait delegations — Default, From, or similar trait impls that are single-line delegations to an already-tested constructor, since they will be covered transitively.

After adding tests, double check that every new test covers at least one branch that no other test (existing or new) covers. Remove any that don't.

Comments

Markdown supported