agentleFS
SebastianKuehnauSebastianKuehnau/sandbox-demo/.claude/skills/use-case-tests/SKILL.md

use-case-tests

Skill0 starsChanged 3 months agoUnlicenseView on GitHub

Write and run tests for a use case. Use when writing tests for an implemented use case.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    One folder per use case: Place the class (and any supporting fixtures) in …

    line 13
  2. Distinctive:

    Method names map directly to the spec: Use the segments from the use-case document so a reader can jump from a failing test back to the …

    line 14
  3. Very specific:

    Plain Spring @SpringBootTest: when a flow or business rule is best verified directly against a @Service (no UI involved).

    line 25
  4. Distinctive:

    If a test doesn't map to Main Flow, an AF, or a BR, either it belongs to a different use case or the spec is missing the rule it covers — …

    line 38

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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

Writing Tests for a Use Case

Tests are organized around the use case, not around individual views or layers. A use case may span multiple views, services, and packages — its tests live together so the use case's behaviour can be read and run as a single unit.

Structure

  • One test class per use case. Name it after the use case: UC001BrowseMovies, UC002BuyTickets, etc. The UC-NNN prefix is the traceability link back to spec/use-cases/use-case-NNN-*.md.
  • One folder per use case. Place the class (and any supporting fixtures) in src/test/java/com/example/specdriven/usecases/uc001_browse_movies/ (or src/test/frontend/usecases/uc-001-browse-movies/ for tests that must run in the browser). Folder name mirrors the spec filename.
  • Method names map directly to the spec. Use the segments from the use-case document so a reader can jump from a failing test back to the exact line of spec it covers:
    • mainFlow_* — one method per scenario through the Main Flow.
    • af1_*, af2_*, … — one method per Alternative Flow, named for its condition.
    • br01_*, br02_*, … — one method per Business Rule.

Choosing the test mechanism

The tech is an implementation detail picked per method, not per use case. Within a single use-case class, mix as needed:

  • Vaadin Browserless Test (SpringBrowserlessTest, @SpringBootTest) for Flow views. Use navigate(ViewClass.class), $(ComponentClass.class), test(component). Use @WithMockUser(roles = "ADMIN") for admin areas, @WithAnonymousUser for access-control checks.
  • Vitest + React Testing Library for Hilla/React views. Lives under src/test/frontend/usecases/uc-NNN-*/. Mock @BrowserCallable endpoints.
  • Plain Spring @SpringBootTest when a flow or business rule is best verified directly against a @Service (no UI involved). Prefer testing the service over the @BrowserCallable endpoint.

A use case that combines an admin curation flow with a public browse flow ends up with both browserless and (if applicable) Vitest tests sharing the same UC0xx* name and the same per-use-case folder. They are the same use case's tests, written in whichever mechanism fits each step.

Coverage Requirements

The use case's flows and business rules are the acceptance criteria. There is no separate acceptance-criteria list. Every test method must trace to one of:

  • Main Flow — at least one mainFlow_* test exercising the happy path end to end.
  • Alternative Flows — one afN_* test per AF-N, triggering its condition and asserting its branch.
  • Business Rules — one brNN_* test per BR-N, especially edge cases (limits, validation, error handling).
  • Postconditions — asserted inside the relevant flow tests.

If a test doesn't map to Main Flow, an AF, or a BR, either it belongs to a different use case or the spec is missing the rule it covers — fix the spec, don't orphan the test.

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.