Rust testing
Skill ulpi-io/plugin-marketplace/plugins/pproenca/skills/rust-testing
Rust testing patterns for CLI applications, libraries, and frameworks. This skill should be used when writing, reviewing, or refactoring Rust tests including unit tests, integration tests, mocking, async testing, and CI integration. Triggers on tasks involving Rust testing, cargo test, mockall, proptest, tokio test, or test organization.From its SKILL.md
npx -y skills add ulpi-io/plugin-marketplace --skill rust-testingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.6 KB, ~1.5k tokens by cl100k_base, as published. Nobody here has run it
Rust Testing Best Practices
Comprehensive testing guide for Rust applications, covering CLI testing, library testing, async patterns, and CI integration. Contains 42 rules across 8 categories, prioritized by impact to guide test design, mocking strategies, and CI optimization.
When to Apply
Reference these guidelines when:
- Writing unit tests for Rust libraries or modules
- Creating integration tests for CLI applications
- Setting up mocking with mockall or trait-based design
- Testing async code with Tokio
- Configuring CI pipelines for Rust projects
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Test Organization | CRITICAL | org- |
| 2 | Mocking and Test Doubles | CRITICAL | mock- |
| 3 | Async Testing | HIGH | async- |
| 4 | Property-Based Testing | HIGH | prop- |
| 5 | Test Fixtures and Setup | MEDIUM | fix- |
| 6 | Assertions and Error Testing | MEDIUM | assert- |
| 7 | CI Integration | MEDIUM | ci- |
| 8 | Test Performance | LOW-MEDIUM | perf- |
Quick Reference
1. Test Organization (CRITICAL)
org-unit-test-modules- Use cfg(test) modules for unit testsorg-integration-tests-directory- Place integration tests in tests directoryorg-shared-test-utilities- Use tests/common/mod.rs for shared utilitiesorg-binary-crate-pattern- Extract logic from main.rs into lib.rsorg-test-naming- Name tests after behavior not implementationorg-test-cli-with-assert-cmd- Use assert_cmd for CLI testing
2. Mocking and Test Doubles (CRITICAL)
mock-trait-based-design- Design for testability with traitsmock-automock-attribute- Use mockall automock for complex mockingmock-avoid-mocking-owned-types- Avoid mocking types you ownmock-expect-call-counts- Verify mock call counts explicitlymock-predicate-arguments- Use predicates to verify mock argumentsmock-returning-sequences- Use sequences for multiple return valuesmock-static-methods- Use mock! macro for static methods
3. Async Testing (HIGH)
async-tokio-test-macro- Use tokio::test for async test functionsasync-time-control- Use paused time for timeout testingasync-mock-io- Use tokio_test for mocking async IOasync-spawn-blocking- Test spawn_blocking with multi-threaded runtimeasync-test-channels- Use channels for testing async communication
4. Property-Based Testing (HIGH)
prop-proptest-basics- Use proptest for property-based testingprop-custom-strategies- Create custom strategies for domain typesprop-shrinking- Use shrinking to find minimal failing casesprop-invariant-testing- Test invariants instead of specific values
5. Test Fixtures and Setup (MEDIUM)
fix-rstest-fixtures- Use rstest fixtures for test setupfix-rstest-parametrized- Use rstest case for parameterized testsfix-temp-directories- Use TempDir for file system testsfix-test-context- Use test-context for setup and teardownfix-once-cell-shared-state- Use OnceCell for expensive shared setup
6. Assertions and Error Testing (MEDIUM)
assert-specific-errors- Assert specific error types not just is_errassert-should-panic- Use should_panic for panic testingassert-debug-display- Implement Debug for clear failure messagesassert-custom-messages- Add context to assertions with custom messagesassert-floating-point- Use approximate comparison for floating pointassert-collection-contents- Assert collection contents not just length
7. CI Integration (MEDIUM)
ci-cargo-nextest- Use cargo-nextest for faster CIci-caching- Cache Cargo dependencies in CIci-test-isolation- Ensure test isolation in parallel CIci-coverage- Generate coverage reports in CI
8. Test Performance (LOW-MEDIUM)
perf-compile-time- Reduce test compilation timeperf-test-filtering- Filter tests for faster feedback loopsperf-avoid-io-in-unit-tests- Avoid real IO in unit testsperf-parallel-test-execution- Configure parallel test threadsperf-benchmark-critical-paths- Benchmark critical paths with Criterion
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
What ships with it: 47 files
115.9 KB alongside SKILL.md
assets/
references/
- assert-collection-contents.md3.1 KB
- assert-custom-messages.md3.0 KB
- assert-debug-display.md2.8 KB
- assert-floating-point.md2.7 KB
- assert-should-panic.md2.6 KB
- assert-specific-errors.md2.9 KB
- async-mock-io.md2.6 KB
- async-spawn-blocking.md2.4 KB
- async-test-channels.md3.1 KB
- async-time-control.md2.8 KB
- async-tokio-test-macro.md2.1 KB
- ci-caching.md2.6 KB
- ci-cargo-nextest.md2.2 KB
- ci-coverage.md2.1 KB
- ci-test-isolation.md2.8 KB
- fix-once-cell-shared-state.md2.8 KB
- fix-rstest-fixtures.md2.3 KB
- fix-rstest-parametrized.md2.2 KB
- fix-temp-directories.md2.7 KB
- fix-test-context.md2.8 KB
- mock-automock-attribute.md2.7 KB
- mock-avoid-mocking-owned-types.md2.9 KB
- mock-expect-call-counts.md2.7 KB
- mock-predicate-arguments.md2.6 KB
- mock-returning-sequences.md2.8 KB
- mock-static-methods.md2.5 KB
- mock-trait-based-design.md2.8 KB
- org-binary-crate-pattern.md2.5 KB
- org-integration-tests-directory.md2.2 KB
- org-shared-test-utilities.md2.3 KB
- org-test-cli-with-assert-cmd.md2.3 KB
- org-test-naming.md2.3 KB
- org-unit-test-modules.md2.0 KB
- perf-avoid-io-in-unit-tests.md3.0 KB
- perf-benchmark-critical-paths.md2.3 KB
- perf-compile-time.md2.4 KB
- perf-parallel-test-execution.md2.2 KB
- perf-test-filtering.md2.4 KB
- metadata.json1011 B
7 more files not listed here. See all 47 in the repository.