install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/RediSearch/RediSearch/rust-tests-guidelines" ~/.claude/skills/comeonoliver-skillshub-rust-tests-guidelines && rm -rf "$T"
manifest:
skills/RediSearch/RediSearch/rust-tests-guidelines/SKILL.mdsource content
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
whenever you are testing output that is difficult to predict or compare.insta - Where appropriate, use
to add property-based tests for key invariants.proptest - 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
directory of the relevant crate if they don't rely on private APIs.tests - The
directory should be organized as a crate, with atests
file and all tests in modules. Refer to themain.rs
directory as an example.trie_rs/tests - If the test must rely on private APIs, co-locate them with the code they test, using a
module.#[cfg(test)]
Dealing with extern C symbols
Check out CONTRIBUTING.md for instructions on how to deal with undefined C symbols in Rust tests.