with one click
use-case-tests
// Write and run tests for a use case. Use when writing tests for an implemented use case.
// Write and run tests for a use case. Use when writing tests for an implemented use case.
Implement a use case from the spec/ folder. Use when asked to implement, build, or work on a use case.
Define a new use case by interviewing the user, then write a filled-in `spec/use-cases/use-case-NNN-short-name.md`. Use when the user wants to add, draft, or specify a new feature/use case.
Visually verify an implemented use case using Playwright MCP. Use after implementing UI changes.
| name | use-case-tests |
| description | Write and run tests for a use case. Use when writing tests for an implemented 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.
UC001BrowseMovies, UC002BuyTickets, etc. The UC-NNN prefix is the traceability link back to spec/use-cases/use-case-NNN-*.md.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.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.The tech is an implementation detail picked per method, not per use case. Within a single use-case class, mix as needed:
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.src/test/frontend/usecases/uc-NNN-*/. Mock @BrowserCallable endpoints.@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.
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:
mainFlow_* test exercising the happy path end to end.afN_* test per AF-N, triggering its condition and asserting its branch.brNN_* test per BR-N, especially edge cases (limits, validation, error handling).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.