-
Notifications
You must be signed in to change notification settings - Fork 0
Feature Test
Ali Sadeghi edited this page Feb 5, 2026
·
4 revisions
Generates comprehensive tests for a KMP feature module.
Usage:
/feature-test login- Discovery - Detects namespaces and extracts feature context (models, DataSource, Repository, ViewModel, Screen)
-
Dependencies - Adds test dependencies to
build.gradle.ktsif missing - Sync - Requests project sync before test generation
-
Fixtures - Spawns
test-fixturesagent (must complete first) -
Data Layer Tests - Spawns
test-datasource+test-repositoryin parallel -
Presentation Tests - Spawns
test-viewmodel+test-ui+test-integrationin parallel - Validation - Runs tests and generates Kover coverage report
Phase 1: Discovery
└── Extract context (YAML summaries, not full code)
↓
Phase 2: Sync
└── User confirms project sync
↓
Phase 3: Fixtures
└── test-fixtures (must complete first - others depend on it)
↓
Phase 4: Data Layer (parallel)
├── test-datasource
└── test-repository
↓
Phase 5: Presentation (parallel)
├── test-viewmodel
├── test-ui
└── test-integration
↓
Phase 6: Validation
└── Run tests + Generate Kover coverage
Max parallel agents: 3 (memory-safe)
| Agent | What It Generates | Dependencies |
|---|---|---|
| test-fixtures |
{Feature}Fixtures.kt + {Feature}UiFixtures.kt
|
None (runs first) |
| test-datasource | {Feature}RemoteDataSourceTest.kt |
Fixtures |
| test-repository | {Feature}RepositoryImplTest.kt |
Fixtures |
| test-viewmodel | {Feature}ViewModelTest.kt |
Fixtures |
| test-ui |
{Feature}ScreenTest.kt (targets ScreenRoot) |
UiFixtures |
| test-integration | {Feature}IntegrationTest.kt |
Fixtures |
feature/{name}/src/commonTest/kotlin/{pkg}/{name}/
├── fixtures/
│ ├── {Feature}Fixtures.kt # Domain model factories
│ └── {Feature}UiFixtures.kt # UiState factories (4 states)
├── data/
│ ├── datasource/
│ │ └── {Feature}RemoteDataSourceTest.kt
│ └── repository/
│ └── {Feature}RepositoryImplTest.kt
├── presentation/
│ └── {Feature}ViewModelTest.kt
└── integration/
└── {Feature}IntegrationTest.kt
feature/{name}/src/desktopTest/kotlin/{pkg}/{name}/
└── presentation/
└── ui/
└── {Feature}ScreenTest.kt
If .claude/docs/{featurename}/spec.md exists:
- Extracts FR-X.Y requirement scenarios
- Passes scenarios to ViewModel/UI agents
- Maps test methods to spec requirements
- Reports spec coverage percentage
All test agents use standardized error handling:
-
ErrorConst.NoNetwork,ErrorConst.Unauthorized,ErrorConst.ServerUnknownError - JSON error responses:
{"detail": "...", "code": ...}
Test Generation Complete: login
Generated:
- LoginFixtures.kt (12 factories, 5 error constants)
- LoginUiFixtures.kt (8 UI state factories)
- LoginRemoteDataSourceTest.kt (18 tests)
- LoginRepositoryImplTest.kt (12 tests)
- LoginViewModelTest.kt (15 tests)
- LoginScreenTest.kt (10 tests)
- LoginIntegrationTest.kt (8 tests)
Total: 63 tests
Spec Coverage: 94% (17/18 scenarios covered)
Coverage Report: feature/login/build/reports/kover/html/index.html
- Line: 87% | Branch: 82%
# Run tests manually
./gradlew :feature:{name}:desktopTest
# Run specific test class
./gradlew :feature:{name}:desktopTest --tests "*ViewModelTest"
# View coverage report
open feature/{name}/build/reports/kover/html/index.html- Discovery extracts YAML summaries only (never full file contents)
- Fixtures must complete before other agents spawn
- UI tests target ScreenRoot, not Screen wrapper
- Workers do NOT re-read source files - they use pre-computed context
Back to Commands