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.
In this repository3 other files it gives its agents.
- implement-use-caseSkill
- new-use-caseSkill
- visual-verificationSkill
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
- Very specific: line 13
One folder per use case: Place the class (and any supporting fixtures) in …
- Distinctive: line 14
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 …
- Very specific: line 25
Plain Spring
@SpringBootTest: when a flow or business rule is best verified directly against a @Service (no UI involved). - Distinctive: line 38
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 — …
≈ “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.
Files
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. TheUC-NNNprefix is the traceability link back tospec/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/(orsrc/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. Usenavigate(ViewClass.class),$(ComponentClass.class),test(component). Use@WithMockUser(roles = "ADMIN")for admin areas,@WithAnonymousUserfor access-control checks. - Vitest + React Testing Library for Hilla/React views. Lives under
src/test/frontend/usecases/uc-NNN-*/. Mock@BrowserCallableendpoints. - Plain Spring
@SpringBootTestwhen a flow or business rule is best verified directly against a@Service(no UI involved). Prefer testing the service over the@BrowserCallableendpoint.
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 perAF-N, triggering its condition and asserting its branch. - Business Rules — one
brNN_*test perBR-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.
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
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.

