rust-tests-guidelines

Guidelines for Writing Rust Tests

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "rust-tests-guidelines" with this command: npx skills add redisearch/redisearch/redisearch-redisearch-rust-tests-guidelines

Guidelines for Writing Rust Tests

Guidelines for writing new tests for Rust code.

Guidelines

  • Test against the public API of the code under test.

  • Test private APIs if and only if the private component is highly complex and difficult to test through the public API.

  • Use insta whenever you are testing output that is difficult to predict or compare.

  • Where appropriate, use proptest to add property-based tests for key invariants.

  • 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.

  • Do not reference exact line numbers in comments, as they may change over time.

Code organization

  • Put tests under the tests directory of the relevant crate if they don't rely on private APIs.

  • 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.

  • 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 for instructions on how to deal with undefined C symbols in Rust tests.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

write-rust-tests

No summary provided by upstream source.

Repository SourceNeeds Review
General

check-rust-coverage

No summary provided by upstream source.

Repository SourceNeeds Review
General

analyze-rust-ffi-crate-surface

No summary provided by upstream source.

Repository SourceNeeds Review
General

run-rust-tests

No summary provided by upstream source.

Repository SourceNeeds Review