Skip to content

Feature Test

Ali Sadeghi edited this page Jan 27, 2026 · 4 revisions

Feature Test

Generates comprehensive tests for a KMP feature module.

Usage:

/feature-test login
/feature-test profile
/feature-test productcatalog

What Gets Generated

Test Type Output Path Coverage
Fixtures .../fixtures/{Feature}Fixtures.kt Domain model factories
UI Fixtures .../fixtures/{Feature}UiFixtures.kt UiState factories for all 4 states
DataSource .../data/datasource/{Feature}RemoteDataSourceTest.kt MockEngine HTTP tests
Repository .../data/{Feature}RepositoryImplTest.kt Mokkery mock tests
ViewModel .../presentation/{Feature}ViewModelTest.kt Turbine StateFlow tests
UI .../presentation/ui/{Feature}ScreenTest.kt Compose UI tests (ScreenRoot)
Integration .../integration/{Feature}IntegrationTest.kt Full-stack E2E tests

How It Works

  1. Validates feature exists in feature/{name}/
  2. Invokes the test-orchestrator agent
  3. Discovers all feature files and extracts structured context
  4. Generates fixtures first (domain + UI fixtures)
  5. Parallel Phase 1 - DataSource + Repository tests
  6. Parallel Phase 2 - ViewModel + UI + Integration tests
  7. Runs tests via ./gradlew :feature:{name}:desktopTest
  8. Generates coverage via Kover HTML report

Spec-Aware Testing

If .claude/docs/{featurename}/spec.md exists, the command will:

  • Extract requirement scenarios from the spec
  • Pass scenarios to ViewModel and UI test agents
  • Map generated tests to spec requirements
  • Report spec coverage in the summary

Example Output

## Test Generation Summary: login

| Test Type | Status | Tests | File |
|-----------|--------|-------|------|
| Fixtures || - | .../fixtures/LoginFixtures.kt |
| DataSource || 25 | .../data/datasource/LoginRemoteDataSourceTest.kt |
| Repository || 35 | .../data/LoginRepositoryImplTest.kt |
| ViewModel || 40 | .../presentation/LoginViewModelTest.kt |
| UI || 30 | .../presentation/ui/LoginScreenTest.kt |
| Integration || 15 | .../integration/LoginIntegrationTest.kt |

**Coverage Report:** feature/login/build/reports/kover/html/index.html
- Line Coverage: 87%
- Branch Coverage: 82%

After Completion

# Run tests manually
./gradlew :feature:{name}:desktopTest

# View coverage report
open feature/{name}/build/reports/kover/html/index.html

# Run specific test class
./gradlew :feature:{name}:desktopTest --tests "*ViewModelTest"

Notes

  • Tests follow the ScreenRoot pattern - UI tests target {Feature}ScreenRoot, not {Feature}Screen
  • All tests use fixtures for test data consistency
  • Database tests only generated if .sq SQLDelight files exist
  • Coverage threshold is 80% (configured in Kover)

Back to Commands

Clone this wiki locally