write-rust-tests

Automate Rust unit and integration tests with cargo test.

6.2k|590|Updated May 5, 2016
One-click install
npx skills add https://github.com/RediSearch/RediSearch --skill write-rust-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-rust-tests
Source: https://github.com/RediSearch/RediSearch/tree/main/.skills/write-rust-tests
Command: npx skills add https://github.com/RediSearch/RediSearch --skill write-rust-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps engineers ensure Rust code correctness by guiding the creation and execution of tests, reducing regressions and manual debugging effort.

Core Features & Use Cases

  • Unit testing: Validate individual functions and modules using cargo test.
  • Integration testing: Verify crate interactions and multi-crate workflows across a workspace.
  • Test guidelines: Align with Rust testing best practices and project-specific coverage goals.

Quick Start

Run cargo test in your Rust workspace to execute all tests and collect results.

Frequently Asked Questions about write-rust-tests

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

FAQPage Schema
How do I run tests in a Rust project with Cargo?

Run cargo test in your Rust workspace to execute all unit and integration tests. Cargo compiles your test code and runs it, collecting and displaying results automatically according to Rust testing guidelines.

What's the difference between unit tests and integration tests in Rust?

Unit tests validate individual functions and modules within source files using #[test] attributes. Integration tests verify interactions between crates and multi-crate workflows in separate test directories, ensuring your Cargo workspace components work together correctly.

Can I run tests across multiple crates in a Rust workspace?

Yes. cargo test runs unit and integration tests across all crates in your workspace simultaneously. Each crate's tests execute in isolation, and results aggregate into a single report showing overall correctness.

How do I organize integration tests in a Cargo project?

Place integration tests in a tests/ directory at the workspace root. Cargo treats each file as a separate crate. Use cargo test to run them alongside unit tests, verifying both internal module correctness and inter-crate interactions.

What testing guidelines should I follow in Rust?

Rust testing guidelines recommend using #[test] attributes for unit tests, organizing integration tests in tests/, naming tests descriptively, and running cargo test regularly. This aligns with Cargo's standard testing workflow and reduces regressions.

Does Cargo automatically compile and run my tests?

Yes. cargo test compiles your test code and runs it automatically. It handles compilation, execution, and result collection in a single command, eliminating manual verification steps.