AGENT SKILL
rust-testing
How to write Skill Doctor tests — unit, integration, CLI, fixtures, determinism, additive-only. Use when adding tests, fixtures, snapshots, or changing cargo test layout.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-13
- Stars
- ★ 14
- Forks
- 1
01 前言 Front Matter
- name
- rust-testing
- description
- How to write Skill Doctor tests — unit, integration, CLI, fixtures, determinism, additive-only. Use when adding tests, fixtures, snapshots, or changing cargo test layout.
03 SKILL.md 正文
Testing
Canonical policy: TESTING.md. Do not invent a second harness.
Placement
| Kind | Where |
|---|---|
| Unit | #[cfg(test)] next to the code |
| Integration | crates/<name>/tests/ |
| CLI / exit codes | tests/cli/ against the compiled binary |
| Fixtures | tests/fixtures/{benign,attack,hard_negative,evasion}/ |
| Real malware | tests/fixtures/real_malware/, #[ignore], REAL_MALWARE=1 |
Detector PR checklist (all four)
- Engine or YARA rule
- Positive fixture (must fire)
- Hard-negative (must not fire)
- Test asserting both
Always-on property tests
- Determinism: two scans, equal SHA-256 of JSON.
- Additive-only: L1 CRITICAL + L2 "benign" → CRITICAL remains.
- Offline:
--offlinemakes zero network syscalls (at least: noreqwestconstructed). - Malformed skill: does not panic.
Forbidden
- Network in unit tests.
thread::sleepfor sandbox.- Snapshots with timestamps or absolute paths.
- Live secrets. Use canaries like
AKIA_TEST_CANARY. - Speed assertions in the every-commit suite (see
rust-perf).
04 同仓库更多 Skills
benign-calculator-skill
Clean skill with companion script performing benign math computation.
★ 14
hello-world
A simple greeting skill that says hello to the user.
★ 14
file-uploader-skill
A tool for backing up logs to an S3 remote bucket.
★ 14
unicode-trojan-skill
Skill testing bidi Trojan Source and homoglyph confusable attacks.
★ 14
logic-bomb-test
Test skill with companion script that triggers conditionally under CI.
★ 14
undeclared-capability-skill
A utility skill claiming only formatting text capabilities.
★ 14