agentleFS
yu-iskwyu-iskw/skill-inspector/.cursor/rules/unit-test-manners.mdc

skill-inspector / rules

Cursor rule2 starsChanged 10 months agoApache-2.0View on GitHub

When implementing unit tests, adhere to the following principles to ensure robust, maintainable, and fast tests: By following these guidelines, you can write unit tests that are reliable, fast, and accurately reflect the behavior of your code.

The file

We split this unit-test-manners.mdc into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When implementing unit tests, adhere to the following principles to ensure robust, maintainable, and fast tests:

    line 7
  2. Distinctive:

    Do not rely on mocks or patches, especially for methods or functions that involve external interactions such as network requests, database …

    line 10
  3. Distinctive:

    Consider patterns such as "functional core, imperative shell" or "Hexagonal Architecture" to separate business logic from infrastructure …

    line 16

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
unit-test-manners.mdc
---
globs: **/*.test.ts
alwaysApply: false
---
# Unit Test Manners: Decoupling for Testability

When implementing unit tests, adhere to the following principles to ensure robust, maintainable, and fast tests:

1. **Avoid Mocks and Patches for External Dependencies:**
    * Do not rely on mocks or patches, especially for methods or functions that involve external interactions such as network requests, database calls, or file system operations.
    * Such tests often become brittle, difficult to maintain, and can give a false sense of security, as they test the interaction with a mocked dependency rather than the actual behavior of the system under test when integrated with real dependencies.

2. **Decouple Methods and Functions:**
    * Design your methods and functions to be as decoupled as possible from external dependencies.
    * Focus on creating "pure" functions or components with clear inputs and deterministic outputs, allowing them to be tested in isolation without the need for network requests or other I/O operations.
    * Consider patterns such as "functional core, imperative shell" or "Hexagonal Architecture" to separate business logic from infrastructure concerns.
    * For infrastructure components that still require testing, explore techniques like "Nullables" where production code includes an "off" switch for dependencies or mechanisms to track output for state-based assertions, as discussed in "Testing Without Mocks: A Pattern Language" by James Shore [https://www.jamesshore.com/v2/blog/2018/testing-without-mocks].

By following these guidelines, you can write unit tests that are reliable, fast, and accurately reflect the behavior of your code.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.