Skip to content
Back to skills

Rust Testing

ASecurity

Behavior. Use when writing, consolidating, or reviewing Rust tests: contract selection, proving layer, suite economy, real dependencies, time control, and fault sensitivity.

  • 2 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
developmentrustgosqltesting

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 27, 2026

npx -y skills add Dankosik/rust-service-template-rest --skill rust-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Testing?

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

Security grade badge for Rust Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dankosik-rust-testing/badge)](https://www.skillsdirectory.com/skills/dankosik-rust-testing)

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
---
name: rust-testing
description: "Behavior. Use when writing, consolidating, or reviewing Rust tests: contract selection, proving layer, suite economy, real dependencies, time control, and fault sensitivity."
---

# Rust Testing

**Behavior first.** Read the subsystem's production code before its tests to identify the observable contracts and realistic regressions worth protecting, then select the smallest layer able to watch a defect fail. Assert concrete caller- or operator-visible outcomes (status, body, Problem code and headers, committed rows, published message, telemetry event, or exit code) against independent expected values rather than tautologically re-deriving constants or mirroring internal steps, call order, or private representations. Apply a quick Mutation Mental Test to every new or edited test: mentally invert or delete the production branch it guards and confirm the test would go red.

**Smallest proving layer.** Match the harness to the boundary under test: unit tests beside pure logic, mounted `Router` tests when middleware and extractors participate, bounded loopback listeners for socket behavior, binary process tests for startup/drain/exit codes, and Compose integration suites for real providers. Assert public behavior so internal refactors stay green, while keeping platform and integration tests wherever transport, OS, SQL, or protocol semantics carry distinct behavior that in-memory checks cannot observe.

**Suite economy and consolidation.** Make every added or retained test earn its execution and maintenance cost by catching a realistic regression that types, exhaustive matches, and neighboring tests leave open. Consolidate overlapping cases around the strongest behavior check at that layer—or a compact table of distinct equivalence classes for pure logic—removing obsolete tests, duplicate setup, and unused fixtures instead of padding test counts. Treat independent safety, authorization, secret-redaction, resource-limit, timeout, and durability guards as non-fungible: never trade one away to offset growth elsewhere, and never delete the sole useful regression guard to clear a failing run.

**Real providers versus doubles.** Exercise real PostgreSQL or broker instances via `just test-integration-db` and the Compose recipes in `justfile` whenever provider semantics belong to the claim; reserve test doubles for unavailable external peers, injected faults, or deterministic inputs outside the asserted contract rather than mocking internal collaborators. Keep fixtures minimal—specifying only inputs relevant to the asserted contract—while retaining focused custom wire or body fixtures where tests inject partial reads, mid-stream errors, or cancellation timing beyond library mocks.

**Clocks, synchronization, and flake repair.** Drive paused Tokio time exclusively with Tokio timers (accounting for idle auto-advance), and synchronize concurrent steps on observable state transitions, notifications, or task joins with bounded timeouts rather than wall-clock sleeps. Repair valuable flaky tests at their timing, ordering, or shared-state root cause instead of masking them with retries or widened sleeps. In process tests, resolve built executables from Cargo's test environment or `compiler-artifact` JSON, await readiness before signalling `SIGTERM`, and wait for child termination through the existing harness.

**Fault sensitivity and discovery.** Organize tests by behavior with explicit boundary limits and independent wire fixtures where serialization compatibility matters. Reproduce bugs with a failing test first, verify non-zero executed test counts, and confirm when practical that new or consolidated guards fail for the broken behavior they claim to catch. Use `just mutants <crate> <path>`, property tests, Miri, or fuzzing selectively as discovery aids rather than mandatory completion gates.

Files in this skill

  • LICENSE1 KB
  • SKILL.md3.2 KB

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.