agentleFS
solakpetrisolakpetri/Enzo.Ai.Skills/skills/dotnet-testing/SKILL.md

dotnet-testing

Skill1 starsChanged 3 months agoMITView on GitHub

Create, improve, debug, and review automated tests for .NET and ASP.NET Core applications. Use when writing unit tests, integration tests, API tests, database tests, test fixtures, mocks, fakes, or test infrastructure, and when diagnosing flaky or ineffective .NET tests.

3 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. kevintsengtw/dotnet-testing-agent-skills★ 29same name
    2. AllThingsSmitty/proven-skills★ 1same name
    3. hkarpinen/agent-skills★ 1same name

    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 repository4 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

79 rules. About 0 are common, 73 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈73

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when creating, debugging, or reviewing automated tests in .NET applications.

    line 9
  2. Distinctive:

    Test behavior rather than implementation details.

    line 15
  3. Distinctive:

    Prefer meaningful tests over chasing coverage percentages.

    line 16
  4. Distinctive:

    Prefer tests that increase confidence in important application behavior and catch regressions.

    line 17
  5. Distinctive:

    Avoid tests that merely reproduce implementation details.

    line 18
  6. Distinctive:

    Avoid tests that only prove framework behavior.

    line 19
  7. Distinctive:

    Ensure tests can run independently.

    line 21
  8. Distinctive:

    Start with the behavior you need to prove, then choose the smallest test level that can prove it reliably.

    line 26
  9. Distinctive:

    Use unit tests for isolated business logic.

    line 27
  10. Distinctive:

    Use integration tests when behavior depends on wiring, persistence, serialization, configuration, or framework integration.

    line 28
  11. Distinctive:

    Use API tests when HTTP contracts, filters, middleware, routing, auth, or status codes matter.

    line 29
  12. Distinctive:

    Use end-to-end tests only when the behavior cannot be proved with a smaller, cheaper, more reliable test.

    line 30
  13. Distinctive:

    Do not force everything into unit tests if the important risk is integration behavior.

    line 31
  14. Distinctive:

    Keep the unit under test clear.

    line 35
  15. Distinctive:

    Do not mock the component the test exists to verify.

    line 36
  16. Distinctive:

    Do not mock dependencies automatically.

    line 38
  17. Distinctive:

    Prefer simple object setup over elaborate mocking where possible.

    line 40
  18. Distinctive:

    Use integration tests when the real composition matters.

    line 44
  19. Distinctive:

    Keep the scope intentional.

    line 46
  20. Distinctive:

    Test route behavior, model binding, validation, auth, status codes, and response contracts at the HTTP boundary.

    line 51
  21. Distinctive:

    Keep API tests focused on externally observable behavior.

    line 52
  22. Distinctive:

    Verify error payloads and problem responses when they are part of the contract.

    line 53
  23. Distinctive:

    Use end-to-end tests sparingly for cross-process or full-environment behavior that lower test levels cannot cover.

    line 58
  24. Distinctive:

    Keep them small in number and high in value.

    line 59
  25. Distinctive:

    Avoid relying on them for fast feedback on ordinary business logic.

    line 60
  26. Distinctive:

    Keep tests easy to scan.

    line 64
  27. Distinctive:

    Avoid mixing multiple unrelated behaviors into one test.

    line 66
  28. Distinctive:

    Prefer one logical act per test unless the scenario itself requires a sequence.

    line 67
  29. Distinctive:

    Follow existing repository naming conventions.

    line 71
  30. Distinctive:

    Use names that describe the behavior and relevant condition.

    line 72
  31. Distinctive:

    Keep assertions specific and behavior-focused.

    line 73
  32. Distinctive:

    Prefer clear failure messages or readable assertion styles when the repository already uses them.

    line 75
  33. Distinctive:

    Test business rules directly and cover the meaningful edges.

    line 79
  34. Distinctive:

    Use parameterized tests when the same behavior should hold across multiple inputs.

    line 80
  35. Distinctive:

    Do not hide complex scenario meaning in oversized data tables.

    line 81
  36. Distinctive:

    Keep the parameters readable enough that failures are easy to diagnose.

    line 82
  37. Distinctive:

    Use mocks, stubs, fakes, or in-memory substitutes according to the repository's established patterns.

    line 86
  38. Distinctive:

    Verify dependency calls only when the interaction itself is meaningful behavior.

    line 87
  39. Distinctive:

    Avoid interaction-heavy tests when observable outputs or state changes prove the behavior more directly.

    line 88
  40. Distinctive:

    Avoid uncontrolled system time.

    line 93
  41. Very specific:

    Prefer TimeProvider or an equivalent abstraction when time affects behavior.

    line 94
  42. Distinctive:

    Use deterministic seeds or fixed values when randomness matters.

    line 96
  43. Distinctive:

    Do not let the current clock, timezone, locale, or machine state leak into test outcomes unless the test is explicitly about that behavior.

    line 97
  44. Very specific:

    Avoid .Result, .Wait(), and sync-over-async in tests.

    line 103
  45. Very specific:

    Never use arbitrary Thread.Sleep or Task.Delay as a workaround for flaky tests.

    line 104
  46. Distinctive:

    Do not assume EF Core InMemory behaves like a relational database.

    line 108
  47. Distinctive:

    Prefer the closest practical relational engine already used by the repository.

    line 109
  48. Distinctive:

    Use the real provider or an appropriate disposable relational database when SQL translation, constraints, migrations, transactions, or …

    line 110
  49. Distinctive:

    Use EF Core InMemory only when its limitations are acceptable for the specific behavior.

    line 111
  50. Distinctive:

    Test constraints, transactions, query behavior, concurrency, and relational semantics against a realistic store.

    line 112
  51. Very specific:

    Use WebApplicationFactory where appropriate for ASP.NET Core API integration tests.

    line 117
  52. Distinctive:

    Prefer exercising the application through its real HTTP pipeline when routing, filters, middleware, auth, JSON configuration, or DI wiring …

    line 118
  53. Distinctive:

    Keep test-only service replacements explicit and minimal.

    line 120
  54. Very specific:

    Test protected endpoints for 401, 403, and successful authorized access where relevant.

    line 124
  55. Distinctive:

    Verify resource-level authorization when the application enforces ownership, scope, role, or policy checks.

    line 126
  56. Distinctive:

    Do not call real third-party APIs from normal automated tests.

    line 130
  57. Distinctive:

    Test timeout, retry-safe failure handling, error mapping, and malformed response handling where relevant.

    line 132
  58. Distinctive:

    Keep external contract assumptions visible in test setup and assertions.

    line 133
  59. Distinctive:

    Test repeated and concurrent requests when verifying idempotency.

    line 138
  60. Distinctive:

    Verify the observable guarantees: single effective state change, safe duplicate handling, conflict behavior, or invariant protection.

    line 139
  61. Distinctive:

    Use synchronization primitives or controlled orchestration when needed.

    line 140
  62. Distinctive:

    Keep fixtures predictable and easy to understand.

    line 145
  63. Distinctive:

    Use builders or factory helpers to highlight relevant data and hide irrelevant setup.

    line 146
  64. Distinctive:

    Do not let helpers become a second application layer inside the test suite.

    line 147
  65. Distinctive:

    Keep shared state tightly controlled.

    line 148
  66. Distinctive:

    Treat flaky tests as defects.

    line 152
  67. Distinctive:

    Remove nondeterminism instead of increasing sleeps or retries.

    line 153
  68. Distinctive:

    If a test is flaky, identify whether the issue is timing, shared state, environment dependence, async misuse, or hidden ordering.

    line 154
  69. Distinctive:

    Add regression tests when fixing bugs where practical.

    line 155
  70. Distinctive:

    Do not test private implementation details directly unless the repository explicitly does so and there is no better seam.

    line 160
  71. Distinctive:

    Do not write tests that mirror the code line by line.

    line 161
  72. Distinctive:

    Do not test framework behavior that the application does not customize.

    line 162
  73. Distinctive:

    Do not assert incidental details that make refactoring harder without increasing confidence.

    line 163
  74. Distinctive:

    Add only the setup needed for the scenario.

    line 170
  75. Distinctive:

    Run the targeted tests after implementation.

    line 171
  76. Distinctive:

    Run the broader affected test suite when practical.

    line 172
  77. Distinctive:

    If the change fixes a bug, add a regression test when practical.

    line 173
  78. Distinctive:

    If EF Core is involved, does the test use an appropriate database strategy for the behavior under test?

    line 188
  79. Very specific:

    If ASP.NET Core is involved, should this be covered with WebApplicationFactory?

    line 189

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
SKILL.md

Dotnet Testing

Use this skill when creating, debugging, or reviewing automated tests in .NET applications.

Inspect the repository's existing test projects before writing tests. Follow its established test frameworks, assertion libraries, mocking libraries, naming conventions, fixture patterns, helper utilities, and project structure. Do not introduce a new test stack when the repository already has one.

Testing Philosophy

  • Test behavior rather than implementation details.
  • Prefer meaningful tests over chasing coverage percentages.
  • Prefer tests that increase confidence in important application behavior and catch regressions.
  • Avoid tests that merely reproduce implementation details.
  • Avoid tests that only prove framework behavior.
  • Keep tests deterministic.
  • Ensure tests can run independently.
  • Avoid test-order dependencies.

Choosing The Test Level

  • Start with the behavior you need to prove, then choose the smallest test level that can prove it reliably.
  • Use unit tests for isolated business logic.
  • Use integration tests when behavior depends on wiring, persistence, serialization, configuration, or framework integration.
  • Use API tests when HTTP contracts, filters, middleware, routing, auth, or status codes matter.
  • Use end-to-end tests only when the behavior cannot be proved with a smaller, cheaper, more reliable test.
  • Do not force everything into unit tests if the important risk is integration behavior.

Unit Tests

  • Keep the unit under test clear.
  • Do not mock the component the test exists to verify.
  • Mock external boundaries when appropriate.
  • Do not mock dependencies automatically; only isolate collaborators that would make the test slow, nondeterministic, or less meaningful.
  • Focus unit tests on business rules, branching logic, invariants, calculations, and edge cases.
  • Prefer simple object setup over elaborate mocking where possible.

Integration Tests

  • Use integration tests when the real composition matters.
  • Cover persistence, dependency injection wiring, configuration, serialization, middleware, and application boundaries that unit tests cannot prove.
  • Keep the scope intentional; integration tests should still target a concrete behavior, not the whole system by default.
  • Reset or isolate state so tests remain independent.

API Tests

  • Test route behavior, model binding, validation, auth, status codes, and response contracts at the HTTP boundary.
  • Keep API tests focused on externally observable behavior.
  • Verify error payloads and problem responses when they are part of the contract.
  • Cover success and failure cases that matter to consumers.

End-To-End Tests

  • Use end-to-end tests sparingly for cross-process or full-environment behavior that lower test levels cannot cover.
  • Keep them small in number and high in value.
  • Avoid relying on them for fast feedback on ordinary business logic.

Arrange / Act / Assert

  • Keep tests easy to scan.
  • Make setup intentional, action singular, and assertions explicit.
  • Avoid mixing multiple unrelated behaviors into one test.
  • Prefer one logical act per test unless the scenario itself requires a sequence.

Test Naming And Assertions

  • Follow existing repository naming conventions.
  • Use names that describe the behavior and relevant condition.
  • Keep assertions specific and behavior-focused.
  • Assert what matters; do not assert every property by default.
  • Prefer clear failure messages or readable assertion styles when the repository already uses them.

Business Rules And Parameterized Tests

  • Test business rules directly and cover the meaningful edges.
  • Use parameterized tests when the same behavior should hold across multiple inputs.
  • Do not hide complex scenario meaning in oversized data tables.
  • Keep the parameters readable enough that failures are easy to diagnose.

Mocks, Stubs, Fakes, And Interaction Verification

  • Use mocks, stubs, fakes, or in-memory substitutes according to the repository's established patterns.
  • Verify dependency calls only when the interaction itself is meaningful behavior.
  • Avoid interaction-heavy tests when observable outputs or state changes prove the behavior more directly.
  • Favor fakes or lightweight test implementations over brittle mocks when that makes tests simpler and more realistic.

Time, Randomness, And Determinism

  • Avoid uncontrolled system time.
  • Prefer TimeProvider or an equivalent abstraction when time affects behavior.
  • Avoid uncontrolled randomness.
  • Use deterministic seeds or fixed values when randomness matters.
  • Do not let the current clock, timezone, locale, or machine state leak into test outcomes unless the test is explicitly about that behavior.

Async Testing

  • Await asynchronous operations correctly.
  • Propagate cancellation when the behavior under test depends on it.
  • Avoid .Result, .Wait(), and sync-over-async in tests.
  • Never use arbitrary Thread.Sleep or Task.Delay as a workaround for flaky tests.

EF Core And Database Testing

  • Do not assume EF Core InMemory behaves like a relational database.
  • Prefer the closest practical relational engine already used by the repository.
  • Use the real provider or an appropriate disposable relational database when SQL translation, constraints, migrations, transactions, or concurrency semantics matter.
  • Use EF Core InMemory only when its limitations are acceptable for the specific behavior.
  • Test constraints, transactions, query behavior, concurrency, and relational semantics against a realistic store.
  • Isolate database state per test or per fixture so tests remain independent.

ASP.NET Core Integration Testing

  • Use WebApplicationFactory where appropriate for ASP.NET Core API integration tests.
  • Prefer exercising the application through its real HTTP pipeline when routing, filters, middleware, auth, JSON configuration, or DI wiring matter.
  • Override configuration and dependencies carefully so the test still reflects production behavior where it matters.
  • Keep test-only service replacements explicit and minimal.

Authentication And Authorization Tests

  • Test protected endpoints for 401, 403, and successful authorized access where relevant.
  • Distinguish unauthenticated behavior from authenticated-but-forbidden behavior.
  • Verify resource-level authorization when the application enforces ownership, scope, role, or policy checks.

External HTTP Integration Testing

  • Do not call real third-party APIs from normal automated tests.
  • Mock or fake the external boundary at the HTTP layer or integration seam already used by the repository.
  • Test timeout, retry-safe failure handling, error mapping, and malformed response handling where relevant.
  • Keep external contract assumptions visible in test setup and assertions.

Concurrency And Idempotency Tests

  • Explicitly test concurrency-sensitive behavior concurrently where practical.
  • Test repeated and concurrent requests when verifying idempotency.
  • Verify the observable guarantees: single effective state change, safe duplicate handling, conflict behavior, or invariant protection.
  • Use synchronization primitives or controlled orchestration when needed; do not rely on timing luck.

Fixtures, Builders, And Shared Infrastructure

  • Reuse shared test infrastructure only when it reduces duplication without hiding important behavior.
  • Keep fixtures predictable and easy to understand.
  • Use builders or factory helpers to highlight relevant data and hide irrelevant setup.
  • Do not let helpers become a second application layer inside the test suite.
  • Keep shared state tightly controlled.

Flaky Tests And Regression Tests

  • Treat flaky tests as defects.
  • Remove nondeterminism instead of increasing sleeps or retries.
  • If a test is flaky, identify whether the issue is timing, shared state, environment dependence, async misuse, or hidden ordering.
  • Add regression tests when fixing bugs where practical.
  • Make regression tests prove the bug scenario and the intended fixed behavior.

What Not To Test

  • Do not test private implementation details directly unless the repository explicitly does so and there is no better seam.
  • Do not write tests that mirror the code line by line.
  • Do not test framework behavior that the application does not customize.
  • Do not assert incidental details that make refactoring harder without increasing confidence.

Test Implementation Workflow

  • Inspect the existing test projects and conventions first.
  • Identify the behavior that actually needs proof.
  • Reuse existing fixtures, helpers, and patterns where they help.
  • Add only the setup needed for the scenario.
  • Run the targeted tests after implementation.
  • Run the broader affected test suite when practical.
  • If the change fixes a bug, add a regression test when practical.

Test Review Checklist

  • Does the test follow the repository's existing test stack and conventions?
  • Does it prove behavior rather than implementation details?
  • Is the chosen test level the smallest one that reliably proves the behavior?
  • Is the test deterministic and independent?
  • Does it avoid test-order dependencies?
  • Are assertions specific, meaningful, and not overly coupled to internals?
  • Are mocks or fakes used intentionally rather than automatically?
  • Is interaction verification used only when the interaction is meaningful behavior?
  • Is time controlled with TimeProvider or an equivalent abstraction when needed?
  • Is randomness controlled?
  • Are async operations awaited correctly without sleeps as synchronization?
  • If EF Core is involved, does the test use an appropriate database strategy for the behavior under test?
  • If ASP.NET Core is involved, should this be covered with WebApplicationFactory?
  • Are 401, 403, and success paths covered for protected endpoints where relevant?
  • Are external HTTP dependencies isolated from real third-party services?
  • Are concurrency and idempotency behaviors tested explicitly where they matter?
  • Is shared test infrastructure helping clarity rather than hiding behavior?
  • Would this test catch the regression it claims to prevent?
  • Were the targeted tests run, and was the broader affected suite run when practical?

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.