testing
Skill36 starsChanged 3 months agoApache-2.0View on GitHub
Comprehensive testing patterns and anti-patterns for writing and reviewing tests
123 other projects use a version of this.
Adopted by
Most recently taken up by
- timmo001/skillstheir own version, first seen Oct 5, 2026
- kortix-ai/sunatheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
- andeeplus/aplustheir own version, first seen Oct 4, 2026
- JetBrains/intellij-communitytheir own version, first seen Oct 3, 2026
- shinpr/codex-workflowstheir own version, first seen Oct 2, 2026
Used with
Projects with it also use oss-pr, pr-automation and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CES-LtdSkilloss-pr
Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.
Also in 3 projects that use this
CES-LtdSkillpr-automation
PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".
Also in 3 projects that use this
ffsshhttiikkSkillcicd
Continuous integration and delivery pipelines
Also in 4 projects that use this
ffsshhttiikkSkillnetworking
Practical application and coding skills for Networking
Also in 3 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 9 projects that use this
Cogni-AI-OUSkilldotfiles
Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.
Also in 3 projects that use this
- +2 more from CES-Ltd
- +1 more from ffsshhttiikk
Other versions123 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 123
- lobehub/lobehub★ 83ksame name
- iOfficeAI/AionUi★ 33ksame name
- JetBrains/intellij-community★ 21ksame name
- kortix-ai/suna★ 20ksame name
- modelcontextprotocol/inspector★ 11ksame name
- microsoft/fast★ 9.7ksame name
- bytebase/dbhub★ 3.6ksame name
- theopenco/llmgateway★ 1.7ksame name
- BankrBot/skills★ 1.2ksame name
- microsoft/CCF★ 875same name
113 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository52 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agent-browserSkill
- arch-specSkill
- code-qualitySkill
- code-reviewSkill
- commitSkill
- coord-delegateSkill
- coord-handoffSkill
- coord-orchestrateSkill
- coord-requestSkill
- coord-reviewSkill
- coord-runSkill
- coord-syncSkill
- dispatchSkill
- edda-releaseSkill
- fleet-epic-splitSkill
- fleet-managerSkill
- fleet-orchestrateSkill
- fleet-pr-loopSkill
- fleet-reviewSkill
- fleet-triadSkill
- fleet-workerSkill
- ground-checkSkill
- health-checkSkill
- intel-scanSkill
- issue-actionSkill
- issue-compactSkill
- issue-createSkill
- issue-intakeSkill
- issue-pipelineSkill
- issue-planSkill
- issue-scanSkill
- parallel-waveSkill
- path-forwardSkill
- plan-decomposeSkill
- plan-validateSkill
- pr-checkSkill
- project-planSkill
- Project PrinciplesSkill
- pr-review-loopSkill
- pr-reviewSkill
- pull-requestSkill
- regression-guardSkill
- skill-aliasSkill
- skill-craftSkill
- skill-testSkill
- spec-review-modesSkill
- tech-debtSkill
- tracking-issueSkill
- verifiable-goal-loopSkill
- fleet-orchestrateSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 3 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 105 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Use this skill when writing tests, reviewing test code, or investigating test failures.
- Distinctive: line 13
Read the relevant reference based on context:
- Very specific: line 52
Convention: All tests live inside #[cfg(test)] mod tests at the bottom of the source file.
- Very specific: line 78
Every test module uses a consistent setup_workspace() helper with AtomicU64 counter for unique temp dirs:
- Distinctive: line 115
Always clean up temp dirs at end of test
- Very specific: line 296
Use setup_workspace() for commands that need a ledger
- Very specific: line 297
Use edda_store::ensure_dirs() for commands that need store state
- Very specific: line 299
Call the command function directly (e.g., decide(), peers()) — don't spawn a process
- Very specific: line 314
Use crate::peers::write_heartbeat() to simulate multi-session scenarios
- Very specific: line 315
Use crate::peers::write_binding() to set up coordination state
- Very specific: line 326
Always init workspace before testing: init_workspace(), init_head(), init_branches_json()
- Very specific: line 327
Use Ledger::open() to get a ledger handle
- Very specific: line 328
Use ledger.iter_events() to verify event contents
- Very specific: line 339
Always clean up project_dir() after tests
“Common” is measured: kept by at least 6 in 10 of the 105 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Testing Skill
Use this skill when writing tests, reviewing test code, or investigating test failures.
Documentation
Read the relevant reference based on context:
| Context | Reference |
| General testing | This document |
| Anti-patterns | Anti-Patterns section below |
| Patterns | Patterns section below |
CLI testing (edda-cli) | CLI Testing section below |
Bridge testing (edda-bridge-claude) | Bridge Testing section below |
Ledger testing (edda-ledger) | Ledger Testing section below |
Store testing (edda-store) | Store Testing section below |
Key Principles
- Integration tests are primary — test at system entry points (CLI commands, hook dispatch)
- Mock at the boundary — only mock external services, not internal code
- Use real infrastructure — real filesystem (tempdir), real ledger, real coordination log
- Test behavior, not implementation — verify outcomes, not internal function calls
Test Organization
This project uses inline tests exclusively — zero tests/ directories across all crates.
crates/edda-cli/
src/
cmd_bridge.rs # #[cfg(test)] mod tests { ... }
cmd_gc.rs # #[cfg(test)] mod tests { ... }
crates/edda-bridge-claude/
src/
dispatch.rs # #[cfg(test)] mod tests { ... } (40+ tests)
peers.rs # #[cfg(test)] mod tests { ... } (25+ tests)
crates/edda-ledger/
src/
ledger.rs # #[cfg(test)] mod tests { ... }Convention: All tests live inside #[cfg(test)] mod tests at the bottom of the source file. Never create separate tests/ directories.
Commands
# Run all tests in workspace
cargo test --workspace
# Run tests for a specific crate
cargo test -p edda-bridge-claude
# Run a specific test by name
cargo test -p edda-bridge-claude -- cross_session_binding
# Run tests matching a pattern
cargo test -- session
# Run tests with output visible
cargo test -- --nocapture
# Run tests with backtrace on failure
RUST_BACKTRACE=1 cargo test -p edda-cliSetup Pattern
Every test module uses a consistent setup_workspace() helper with AtomicU64 counter for unique temp dirs:
#[cfg(test)]
mod tests {
use super::*;
use std::sync::atomic::{AtomicU64, Ordering};
static TEST_COUNTER: AtomicU64 = AtomicU64::new(0);
fn setup_workspace() -> (std::path::PathBuf, edda_ledger::Ledger) {
let n = TEST_COUNTER.fetch_add(1, Ordering::SeqCst);
let tmp = std::env::temp_dir().join(format!(
"edda_test_{}_{n}",
std::process::id()
));
let _ = std::fs::remove_dir_all(&tmp);
let paths = edda_ledger::EddaPaths::discover(&tmp);
edda_ledger::ledger::init_workspace(&paths).unwrap();
edda_ledger::ledger::init_head(&paths, "main").unwrap();
edda_ledger::ledger::init_branches_json(&paths, "main").unwrap();
let ledger = edda_ledger::Ledger::open(&tmp).unwrap();
(tmp, ledger)
}
#[test]
fn my_test() {
let (tmp, ledger) = setup_workspace();
// ... test logic ...
let _ = std::fs::remove_dir_all(&tmp);
}
}Key points:
AtomicU64counter prevents collisions between parallel testsstd::process::id()prevents collisions between test binaries- Always clean up temp dirs at end of test
- For store-based tests, also clean
edda_store::project_dir(pid)
Patterns
Use edda_store for State Tests
#[test]
fn test_peer_coordination() {
let pid = "test_unique_name";
let _ = std::fs::remove_dir_all(edda_store::project_dir(pid));
let _ = edda_store::ensure_dirs(pid);
// Write coordination events
crate::peers::write_binding(pid, "s1", "auth", "db.engine", "postgres");
// Verify via public API
let conflict = crate::peers::find_binding_conflict(pid, "db.engine", "OTHER");
assert!(conflict.is_some());
let _ = std::fs::remove_dir_all(edda_store::project_dir(pid));
}Use setup_workspace() for Ledger Tests
#[test]
fn test_ledger_event() {
let (tmp, ledger) = setup_workspace();
let branch = ledger.head_branch().unwrap();
let parent = ledger.last_event_hash().unwrap();
let tags = vec!["decision".to_string()];
let mut event = edda_core::event::new_note_event(
&branch, parent.as_deref(), "system", "db.engine: postgres", &tags,
).unwrap();
edda_core::event::finalize_event(&mut event);
ledger.append_event(&event, false).unwrap();
let events = ledger.iter_events().unwrap();
assert_eq!(events.len(), 1);
let _ = std::fs::remove_dir_all(&tmp);
}Use Environment Variables for Config Overrides
#[test]
fn test_with_custom_threshold() {
// Override config via env var
std::env::set_var("EDDA_PEER_STALE_SECS", "0");
// ... test logic ...
// Always clean up env vars
std::env::remove_var("EDDA_PEER_STALE_SECS");
}Test Multi-Session Scenarios
#[test]
fn test_cross_session() {
let pid = "test_cross_session";
let _ = std::fs::remove_dir_all(edda_store::project_dir(pid));
let _ = edda_store::ensure_dirs(pid);
// Simulate multiple sessions with heartbeats
let signals = crate::signals::SessionSignals::default();
crate::peers::write_heartbeat(pid, "s1", &signals, Some("auth"));
crate::peers::write_heartbeat(pid, "s2", &signals, Some("billing"));
// Write data from one session
crate::peers::write_binding(pid, "s1", "auth", "key", "value");
// Verify other session can see it
let updates = crate::peers::render_peer_updates(pid, "s2").unwrap();
assert!(updates.contains("value"));
crate::peers::remove_heartbeat(pid, "s1");
crate::peers::remove_heartbeat(pid, "s2");
let _ = std::fs::remove_dir_all(edda_store::project_dir(pid));
}Anti-Patterns
AP-1: Don't Create tests/ Directories
// BAD: Creating tests/integration_test.rs
// This project uses inline tests exclusively
// GOOD: Add tests inside the source file
#[cfg(test)]
mod tests {
use super::*;
// tests here have access to private functions
}AP-2: Don't Mock Internal Code
// BAD: Creating trait abstractions just for testing
trait Storage { fn write(&self, key: &str, value: &str); }
struct MockStorage; // Don't do this
// GOOD: Test through the real code path
#[test]
fn test_decide_writes_binding() {
let (tmp, _ledger) = setup_workspace();
decide(&tmp, "db.engine=postgres", Some("need JSONB"), None).unwrap();
// Verify via public API
let conflict = find_binding_conflict(&pid, "db.engine", "OTHER");
assert!(conflict.is_some());
}AP-3: Don't Test Implementation Details
// BAD: Asserting internal file structure
assert!(fs::read_to_string(path).unwrap().contains("specific_internal_format"));
// GOOD: Test through public API behavior
let result = decide(&tmp, "db.engine=postgres", None, None);
assert!(result.is_ok());
let events = ledger.iter_events().unwrap();
assert_eq!(events.len(), 1);AP-4: Don't Leak Test State
// BAD: Using fixed project IDs that collide
let pid = "test"; // Will collide with other tests!
// GOOD: Use unique IDs and clean up
let pid = "test_specific_scenario_name";
let _ = fs::remove_dir_all(edda_store::project_dir(pid)); // Clean first
let _ = edda_store::ensure_dirs(pid);
// ... test ...
let _ = fs::remove_dir_all(edda_store::project_dir(pid)); // Clean afterAP-5: Don't Forget Env Var Cleanup
// BAD: Setting env var without cleanup
std::env::set_var("EDDA_SESSION_ID", "test");
// test runs... but env var leaks to other tests!
// GOOD: Always remove env vars
std::env::set_var("EDDA_SESSION_ID", "test");
// ... test logic ...
std::env::remove_var("EDDA_SESSION_ID");AP-6: Don't Use Sleep Without Justification
// BAD: Arbitrary sleep
std::thread::sleep(Duration::from_secs(5));
// GOOD: Sleep only when testing time-dependent behavior (e.g., stale detection)
// and use the minimum necessary duration
std::thread::sleep(Duration::from_millis(1100)); // Must exceed 1s mtime granularity
std::env::set_var("EDDA_PEER_STALE_SECS", "0");CLI Testing
Tests for edda-cli commands live in each cmd_*.rs file.
Key patterns:
- Use
setup_workspace()for commands that need a ledger - Use
edda_store::ensure_dirs()for commands that need store state - Set
EDDA_SESSION_IDandEDDA_SESSION_LABELenv vars for session-aware commands - Call the command function directly (e.g.,
decide(),peers()) — don't spawn a process
Example crates:
cmd_bridge.rs: 6 tests coveringdecide(),find_prior_decision(),resolve_session_id()cmd_gc.rs: Tests for garbage collection logiccmd_blob.rs: Tests for blob managementcmd_draft.rs: Tests for draft operations
Bridge Testing
Tests for edda-bridge-claude are the most extensive (~230 tests).
Key patterns:
dispatch.rs: Tests hook dispatch flow (dispatch_session_start,dispatch_user_prompt_submit,dispatch_session_end)peers.rs: Tests coordination protocol (write_binding,write_claim,compute_board_state,render_peer_updates)- Use
crate::peers::write_heartbeat()to simulate multi-session scenarios - Use
crate::peers::write_binding()to set up coordination state
Access notes:
- Inline tests can access
pub(crate)functions (e.g.,compute_board_state,write_heartbeat) - Cross-crate tests must use
pubfunctions only (e.g.,find_binding_conflict)
Ledger Testing
Tests for edda-ledger cover event creation, appending, querying, and branch operations.
Key patterns:
- Always init workspace before testing:
init_workspace(),init_head(),init_branches_json() - Use
Ledger::open()to get a ledger handle - Use
ledger.iter_events()to verify event contents - Events are immutable once appended — test creation, not modification
Store Testing
Tests for edda-store cover project directory management and atomic writes.
Key patterns:
project_id()is deterministic (blake3 hash of normalized path)ensure_dirs()creates the full directory treewrite_atomic()for safe file writes- Always clean up
project_dir()after tests
Checklist for New Tests
Before submitting:
- Test is inside
#[cfg(test)] mod testsin the source file - Uses unique project ID or temp dir (no collisions)
- Cleans up temp dirs and store directories
- Cleans up env vars
- Tests behavior through public/crate API, not internal details
- Passes
cargo test --workspacewith zero failures - No
#[ignore]without explanation
References
- Code quality skill:
.claude/skills/code-quality/SKILL.md - Project principles:
.claude/skills/project-principles/SKILL.md - CLAUDE.md testing conventions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

