| name | Testing & Validation |
| description | Test and validation workflow before commit |
Skill: Testing & Validation
When to use this skill
- BEFORE any commit (mandatory)
- After implementing a feature
- To validate a refactoring
- When in doubt about code quality
Automated script
./.agent/skills/testing/scripts/validate.sh
./.agent/skills/testing/scripts/validate.sh --fix
Validation workflow
Step 1: Format
cargo fmt --all
Automatically formats all code according to Rust conventions.
Step 2: Lint
cargo clippy --all-targets -- -D warnings
Rules:
- NO warnings allowed
- Fix clippy suggestions, don't ignore them with
#[allow(...)]
- If an allow is really necessary, justify it in a comment
Step 3: Tests
cargo test
Rules:
- All tests must pass
- A failing test = no commit
- New tests should cover edge cases
Async Tests (MANDATORY)
When writing #[tokio::test], preventing infinite hangs is critical:
- Always use timeouts for channel operations (
recv().await).
let msg = rx.recv().await.unwrap();
let msg = tokio::time::timeout(std::time::Duration::from_secs(1), rx.recv())
.await
.expect("Timeout waiting for message")?;
- Avoid infinite loops without exit conditions or timeouts.
Step 4: Release verification (optional)
cargo build --release
Do this before a release or to verify optimizations.
Quick commands
cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test
cargo test test_name
cargo test module_name::
cargo test --lib
cargo test --test integration
On failure
Clippy warning
- Read the error message carefully
- Apply clippy's suggestion
- If the suggestion is not applicable, justify with a comment
Test failure
- Identify the failing test
- Check if it's a bug in the code or in the test
- NEVER delete a test to make CI pass
- Fix the code or adapt the test if behavior changed intentionally
Checklist before commit