testing
Skill52 starsChanged 25 days agoMITView on GitHub
Testing patterns and anti-patterns for this codebase. Use when writing tests, reviewing test coverage, or debugging test failures. Triggers on terms like "test", "assert", "coverage", "test suite", "regression".
We split this skill into the rules it gives an agent
16 rules. 0 are common, 13 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 172 edited versions we read keep these.
13
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 43
When generating tests from external sources (like official test suites):
- Distinctive: line 63
After generating tests, verify how many actually compare output:
- Very specific: line 69
If is_ok() count >> assert_eq!
- Very specific: line 79
Before concluding a change is neutral, confirm a generator actually produces the shape it touches.
- Distinctive: line 85
When you find a pre-existing defect that is out of scope to fix, lock in the current behaviour with a test that says so explicitly, rather …
- Distinctive: line 110
When the same predicate exists at several call sites, add a test that the sites agree with each other, not just that each is individually …
- Distinctive: line 123
When a test double stands in for "produce an artifact, then invoke it" (cross-compile a binary then SSH-exec it, build a plugin then load …
- Distinctive: line 144
Test individual functions in isolation
- Very specific: line 145
Place in #[cfg(test)] mod tests within the module
- Distinctive: line 150
Test public API behavior
- Distinctive: line 172
Always verify SIMD produces identical results to scalar reference:
- Distinctive: line 186
Test at SIMD boundaries (16, 32, 64 bytes) and boundary-1, boundary+1.
- Distinctive: line 190
When fixing a bug:
- Distinctive: line 194
Verify the test passes
- Distinctive: line 195
Run full test suite to check for regressions
- Distinctive: line 211
Use descriptive names that explain what's being tested:
“Common” is measured: kept by at least 6 in 10 of the 172 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
Guidelines for writing effective tests that actually verify correctness.
Critical Anti-Pattern: Success-Only Tests
Never write tests that only check for successful execution without verifying output.
Bad Example (YAML test suite bug)
// BAD: Only checks parse success, not correctness
#[test]
fn test_sequence_of_mappings() {
let yaml = b"- name: Alice\n age: 30";
let result = YamlIndex::build(yaml);
assert!(result.is_ok()); // Parser could return completely wrong structure!
}This test passed even when the parser produced ["name", "Alice", "age", 30] instead of [{"name": "Alice", "age": 30}].
Good Example
// GOOD: Verifies actual output matches expected
#[test]
fn test_sequence_of_mappings() {
let yaml = b"- name: Alice\n age: 30";
let index = YamlIndex::build(yaml).unwrap();
let json = index.to_json(yaml);
assert_eq!(json, r#"[{"name":"Alice","age":30}]"#);
}Test Generator Pitfalls
When generating tests from external sources (like official test suites):
1. Don't Skip Cases Based on Content
# BAD: Skips tests containing quotes - misses most real-world cases
if '"' not in expected_output:
generate_comparison_test()
else:
generate_parse_only_test() # No output verification!# GOOD: Properly escape and compare all cases
json_escaped = expected.replace('\\', '\\\\').replace('"', '\\"')
generate_comparison_test(json_escaped)2. Count Actual Comparisons
After generating tests, verify how many actually compare output:
grep -c "assert_eq!" tests/generated_suite.rs
grep -c "is_ok()" tests/generated_suite.rsIf is_ok() count >> assert_eq! count, tests aren't verifying correctness.
3. Benchmark Generators Are Test Coverage Too
A shape that no generator emits is invisible to the entire benchmark suite, so "all benchmarks
neutral" is not evidence about it. In #106 every YAML generator emitted - (dash-space), so
block-sequence items written as a bare - on its own line had zero coverage — and hid a
quadratic path worth up to 16x. The omission was justified by a stale comment claiming the parser
required dash-space, which was never true.
Before concluding a change is neutral, confirm a generator actually produces the shape it
touches. If not, add the pattern first (src/bin/succinctly/yaml_generators.rs and the
YamlPattern enum, plus both yq_bench pattern lists), then measure.
Characterization Tests: Pinning Known-Wrong Behaviour
When you find a pre-existing defect that is out of scope to fix, lock in the current behaviour with a test that says so explicitly, rather than leaving it undocumented:
#[test]
fn test_crlf_sequence_items_characterize_preexisting_bug() {
// CRLF is mishandled independently of this change: `\r` is folded into plain
// scalars as a trailing space, so `a: 1\r\n` yields the string "1 " not 1.
// Verified identical before and after, so this is characterization of an
// existing defect. If CRLF handling is fixed, update the expectation.
let agreed = assert_seq_paths_agree_on(b"-\r\n a: 1\r\n");
assert_eq!(agreed, "[\"a\",\"1 \"]",
"CRLF handling changed - if this is the fix, update this test");
}Three requirements: name it *_characterize_preexisting_bug or similar so nobody mistakes it for
desired behaviour, state in the comment that before/after were verified identical, and tell the
future fixer to update it. The failure message should point at the fix, not the assertion.
This is distinct from a regression test — it asserts what the code does, not what it should do, and is expected to fail when someone fixes the bug.
Invariant Tests Over Duplicated Logic
When the same predicate exists at several call sites, add a test that the sites agree with each
other, not just that each is individually correct. #106 had five seq-item detection sites with
three different predicates; one was quadratic and no test noticed, because every test exercised
one path at a time. The permanent guard asserts uncons, get(i) and uncons_cursor produce
identical values for the same sequence, so re-divergence fails a test instead of shipping.
Pair this with a structural cross-check where one is available. For a predicate derived from the input text, assert it never disagrees with the balanced-parens structure the parser built — that oracle held across the whole real-workload corpus and all 279 valid YAML-suite cases when #106 added it, and it catches classes of bug that example-based tests cannot reach.
Fakes Can't Verify Build-Time/Runtime Feature Agreement
When a test double stands in for "produce an artifact, then invoke it" (cross-compile a binary
then SSH-exec it, build a plugin then load it), the fake only proves the orchestration logic is
correct — it can't prove the real artifact actually has what the invoker assumes. Issue #98's
bench sync cross-compiled its deployed binary with --features cli, while bench orchestrate
invoked bench run <name> on that binary — a subcommand gated behind --features bench-runner
(cli is a strict subset). Every sync.rs unit test used a BuildRunner fake that returns a
placeholder file, so none of them could have caught this: the fake never runs a real cargo build
and is never invoked by a real remote exec. The gap stayed invisible until a live run against a
real node failed at the one thing no fake exercises — running the artifact the real build command
actually produced.
How to apply: for any tool that builds-then-executes across a process/host boundary (cross-
compilation, plugin loading, container images), budget at least one real end-to-end run before
trusting it — not just fake-backed unit coverage. Unit tests over BuildRunner/RemoteExec-style
abstractions verify scheduling and control flow; they cannot verify that the concrete command line
used to build something produces something the concrete command line used to invoke it can run.
Testing Levels
Unit Tests (in-module)
- Test individual functions in isolation
- Place in
#[cfg(test)] mod testswithin the module - Fast, focused, good for edge cases
Integration Tests (tests/ directory)
- Test public API behavior
- Verify end-to-end correctness
- Compare against reference implementations or expected outputs
Property Tests
For data structure invariants:
#[test]
fn property_rank_select_inverse() {
// For all valid inputs, select(rank(x)) should return x
for pos in 0..bitvec.len() {
if bitvec.get(pos) {
let r = bitvec.rank1(pos);
assert_eq!(bitvec.select1(r), Some(pos));
}
}
}SIMD Testing Pattern
Always verify SIMD produces identical results to scalar reference:
#[test]
fn simd_matches_scalar() {
let inputs = generate_test_inputs();
for input in inputs {
let scalar = scalar::process(&input);
let simd = simd::process(&input);
assert_eq!(scalar, simd, "Mismatch for input: {:?}", input);
}
}Test at SIMD boundaries (16, 32, 64 bytes) and boundary-1, boundary+1.
Regression Test Workflow
When fixing a bug:
- First write a failing test that reproduces the bug
- Fix the bug
- Verify the test passes
- Run full test suite to check for regressions
#[test]
fn regression_issue_123_nested_sequences() {
// This specific input caused incorrect output before fix
let yaml = b"- - item";
let index = YamlIndex::build(yaml).unwrap();
let json = index.to_json(yaml);
// Should be nested array, not flat
assert_eq!(json, r#"[["item"]]"#);
}Test Naming
Use descriptive names that explain what's being tested:
// BAD
fn test_1() { ... }
fn test_parse() { ... }
// GOOD
fn test_nested_sequence_produces_nested_json() { ... }
fn test_multiline_scalar_preserves_newlines() { ... }
fn test_empty_mapping_returns_empty_object() { ... }Common Assertions
// Equality with message
assert_eq!(actual, expected, "Context: {}", debug_info);
// Pattern matching for Result
assert!(result.is_ok(), "Failed: {:?}", result.err());
let value = result.unwrap();
// Floating point (avoid direct equality)
assert!((actual - expected).abs() < 1e-10);
// Collection contents (order-independent)
assert_eq!(set1, set2); // HashSet comparisonSee Also
- tests/yaml_test_suite.rs - Generated from official YAML test suite
- tests/json_indexing_tests.rs - JSON parser integration tests
- tests/property_tests.rs - Property-based tests for data structures
Other versions192 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 192
- modelcontextprotocol/servers★ 92ksame name
- lobehub/lobe-chat★ 84ksame name
- lobehub/lobehub★ 84ksame name
- penpot/penpot★ 62ksame name
- meteor/meteor★ 45ksame name
- iOfficeAI/AionUi★ 34ksame name
- garrytan/gbrain★ 31ksame name
- OpenZeppelin/openzeppelin-contracts★ 27ksame name
- tursodatabase/turso★ 25ksame name
- redis/go-redis★ 22ksame name
182 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.
Used alongsideProjects with it also use bundle-dependency-prs, update-library-template 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.
MicrosoftSkillbundle-dependency-prs
Fix broken dependency update PRs and aggregate the ones that work into one PR.
Also in 6 projects that use this
MicrosoftSkillupdate-library-template
Merges the latest Library.Template into this repo (at position of HEAD) and resolves conflicts.
Also in 6 projects that use this
zetaloopSkillassign-copilot
Assigns a GitHub issue to the Copilot coding agent, optionally specifying a custom agent. Use this when asked to assign an issue to Copilot or delegate an issue to CCA.
Also in 3 projects that use this
NVIDIA-NeMoSkillbuild-and-dependency
Build and dependency management for NeMo-RL. Covers Docker image building and running, uv usage, venv setup, and adding dependencies.
Also in 3 projects that use this
timmo001Skillchangeset-scope
Keep all scoped code work contained to the user-defined changeset. Use for implementation, fixes, diagnosis, refactoring, cleanup, and review when explicit instructions, named files, diffs, branches, pull requests, or injected work scopes define the boundary.
Also in 3 projects that use this
NVIDIA-NeMoSkilllinting-and-formatting
Code style guidelines for NeMo-RL (Python and shell). Covers naming, indentation, comments, docstrings, reflection avoidance, and uv usage.
Also in 3 projects that use this
In this repository27 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- benchmark-docsSkill
- bit-optimizationSkill
- commit-msgSkill
- json-semi-indexingSkill
- knowledge-mapSkill
- markdown-tablesSkill
- releaseSkill
- review-adrSkill
- simd-optimizationSkill
- skill-writingSkill
- testingSkill
- update-adr-inventorySkill
- yaml-semi-indexingSkill
- benchmark-docsSkill
- bit-optimizationSkill
- commit-msgSkill
- json-semi-indexingSkill
- knowledge-mapSkill
- markdown-tablesSkill
- releaseSkill
- review-adrSkill
- simd-optimizationSkill
- skill-writingSkill
- update-adr-inventorySkill
- yaml-semi-indexingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

