Cursor rule
.cursor/rules/testing.mdcWriting and organizing tests
Cursor rules
Quality
66/100
Scores the file, not the repository.Length
271 words
6 headings · 2 code blocksRepository
2
— · pushed 443 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Module Testing Pattern78## Overview910This codebase follows a specific pattern for organizing tests: tests for a module should be placed inside a subdirectory of that module called `tests`.1112## Why This Pattern?1314- **Colocation**: Tests are located near the code they test, making them easier to find and maintain15- **Isolation**: Tests are separated from implementation code while still being part of the module16- **Organization**: Multiple test files can be organized within the tests directory17- **Module-specific tests**: Tests that are specific to a module's implementation details stay with that module1819## Implementation2021For a module `foo`, structure the tests as follows:2223```24src/foo/25├── mod.rs # Main module file26├── component1.rs # Module component27├── component2.rs # Module component28└── tests/ # Tests directory29 ├── mod.rs # Test module declaration30 ├── component1_tests.rs # Tests for component131 └── component2_tests.rs # Tests for component232```3334In the main module's `mod.rs`, include the tests module conditionally:3536```rust37// ... module code ...3839// Include tests module when running tests but not in normal builds40#[cfg(test)]41pub mod tests;4243// ... rest of module code ...44```4546## Example4748The `snapshot` module demonstrates this pattern:4950- `src/snapshot/mod.rs` includes the tests module conditionally51- `src/snapshot/tests/` contains test files for components and resources52- Test files use the same imports and naming conventions as the implementation code5354## Usage5556When adding new functionality to a module:571. Create corresponding test(s) in the module's `tests/` directory582. Name test files with a `_tests` suffix (e.g., `component_tests.rs`)593. Ensure all public API components are tested604. Use descriptive test names that explain what's being tested
Also in tyler274/rummage
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| tyler274/rummage.cursor/rules/book_editing.mdc · 2 | Cursor rules | no sections | 4/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/bands_of_light_ui.mdc · 2 | Cursor rules | no sections | 16/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/bevy_rand.mdc · 2 | Cursor rules | styledeploymentdo-not | 61/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/cards.mdc · 2 | Cursor rules | no sections | 24/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/compile_check.mdc · 2 | Cursor rules | build | 28/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/general.mdc · 2 | Cursor rules | no sections | 30/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/git_commits.mdc · 2 | Cursor rules | archtypesgit | 54/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/imagenode.mdc · 2 | Cursor rules | databaseui | 50/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/mtg.mdc · 2 | Cursor rules | no sections | 4/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/mtgjson_importer.mdc · 2 | Cursor rules | no sections | 24/100 | 3 days ago | |
| tyler274/rummage.cursor/rules/save.mdc · 2 | Cursor rules | no sections | 24/100 | 3 days ago |
Diff against .cursor/rules/book_editing.mdc Diff against .cursor/rules/bands_of_light_ui.mdc Diff against .cursor/rules/bevy_rand.mdc Diff against .cursor/rules/cards.mdc Diff against .cursor/rules/compile_check.mdc Diff against .cursor/rules/general.mdc Diff against .cursor/rules/git_commits.mdc Diff against .cursor/rules/imagenode.mdc Diff against .cursor/rules/mtg.mdc Diff against .cursor/rules/mtgjson_importer.mdc Diff against .cursor/rules/save.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 3 days ago | |
| nerds-odd-e/doughnut.cursor/rules/cli.mdc · 49 | Cursor rules | setupbuildteststyle+4 | 96/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 3 days ago |
