Skip to content
Back to skills

Rust Tests Guidelines

ASecurity

Guidelines for writing new tests for Rust code.

  • 67 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 10, 2026
developmentrusttestingapi

Works with

  • api

Security analysis

A100/100

Scanned November 10, 2026

npx -y skills add ComeOnOliver/skillshub --skill rust-tests-guidelines --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Tests Guidelines?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rust Tests Guidelines
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/comeonoliver-rust-tests-guidelines/badge)](https://www.skillsdirectory.com/skills/comeonoliver-rust-tests-guidelines)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Guidelines for Writing Rust Tests

Guidelines for writing new tests for Rust code.

## Guidelines

1. Test against the public API of the code under test.
2. Test private APIs if and only if the private component is highly complex and difficult to test through the public API.
3. Use `insta` whenever you are testing output that is difficult to predict or compare.
4. Where appropriate, use `proptest` to add property-based tests for key invariants.
5. Testing code should be written with the same care reserved to production code.
   Avoid unnecessary duplication, introduce helpers to reduce boilerplate and ensure readability.
   The intent of a test should be obvious or, if not possible, clearly documented.
6. Do not reference exact line numbers in comments, as they may change over time.

## Code organization

1. Put tests under the `tests` directory of the relevant crate if they don't rely on private APIs.
2. The `tests` directory should be organized as a crate, with a `main.rs` file and all tests in modules.
   Refer to the `trie_rs/tests` directory as an example.
3. If the test *must* rely on private APIs, co-locate them with the code they test, using a `#[cfg(test)]` module.

## Dealing with extern C symbols

Check out [CONTRIBUTING.md](../../src/redisearch_rs/CONTRIBUTING.md) for instructions on how to deal with
undefined C symbols in Rust tests.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.