.claude/skills/write-unit-tests/SKILL.md
Use when writing or modifying unit tests in the Alkaa project — triggers on tasks like "add a test", "write tests for X", "test this ViewModel", "cover this use case with tests", or "add unit test coverage".
npx skillsauth add igorescodro/alkaa write-unit-testsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Unit tests in Alkaa are multiplatform-first, fake-based, and structured around a single scenario per test. Tests live in commonTest and run fastest via ./gradlew desktopTest.
references/TEST_EXAMPLES.mdtest if or check if, describe the specific condition and expected outcomereferences/FAKE_PATTERNS.md for all three fake patternsby CoroutinesTestDispatcherImpl() for any coroutine-using test class → see references/TEST_EXAMPLES.mdreferences/TEST_EXAMPLES.mdreferences/TEST_EXAMPLES.md✅ `test if when load tasks fails the error state is returned`
✅ `test if task is updated as completed`
✅ `test if category without name is not added`
❌ testUpdateTask()
❌ test1()
| Rule | Details |
|------|---------|
| Fakes over mocks | Only use mocks for Android/Framework types you cannot interface (e.g., Context) |
| CoroutinesTestDispatcher | Delegate by CoroutinesTestDispatcherImpl() for any coroutine-using test class |
| ViewModel at field level | Construct ViewModel at field level, not inside @BeforeTest |
| runTest for suspend | Use = runTest { } for all suspend test bodies |
| flow.first() | Collect current state with flow.first() |
| require() for narrowing | Use require(state is X) before accessing state-specific properties |
| @BeforeTest cleanup | Call clean() on every fake to reset state between tests |
| Mistake | Fix |
|---------|-----|
| Using mocks for domain interfaces | Create a fake implementing the interface |
| Forgetting CoroutinesTestDispatcher delegation | Add by CoroutinesTestDispatcherImpl() |
| Testing multiple scenarios in one test | Split into separate @Test functions |
| Skipping @BeforeTest cleanup | Add setup() calling clean() on every fake |
| Constructing ViewModel in @BeforeTest | Construct at field level so it shares dispatcher context |
| Omitting Given/When/Then comments | Always add the three comment blocks |
| Vague test names like testUpdate() | Rename to describe the scenario and expected outcome |
write-viewmodel skill for ViewModel construction patternswrite-ui-tests skillwrite-e2e-tests skilldevelopment
A skill for reviewing Android code before it is pushed to production.
documentation
Use when writing a new ViewModel or modifying an existing one in the Alkaa project. Triggers on tasks like "add a ViewModel", "create VM for X screen", "implement state handling", or "connect use case to UI".
testing
Use when writing or modifying UI/Compose instrumented tests in the Alkaa project — triggers on tasks like "add a UI test", "test this composable", "add instrumented test", "test this screen behavior".
documentation
Use when a new feature needs to persist data locally in Alkaa — triggers on tasks like "add database support", "create a new table", "store this data in SQLDelight", or when write-feature Phase 2 requires a new entity in the local database.