-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Goal
Strengthen confidence in gameplay logic and API stability by expanding automated tests: domain edge cases, API contract tests, and snapshot verification of guess evaluations.
Motivation
- Prevent regressions as new features (persistence, validation, variants) land
- Catch subtle duplicate-letter scoring bugs
- Lock in API response structure
Scope
Cover domain services (Issue #8), persistence behaviors (Issue #9 integration-lite), and API endpoints shape (ProblemDetails + success payloads).
Additions
- Domain Unit Tests
- Duplicate letters (target: APPLE, guess: PAPAL, etc.)
- All identical letters (AAAAA scenarios)
- Win on final allowed attempt boundary
- Invalid guess length (ensure exception / validation path)
- Case normalization (input lowercase -> treated correctly)
- Guess Evaluation Matrix
- Table-driven tests enumerating (target, guess, expected pattern) using inline data or MemberData
- API Tests (Minimal)
- Using WebApplicationFactory: start game -> submit guess -> verify DTO shapes
- ProblemDetails scenarios (duplicate guess, max attempts reached, bad length)
- Snapshot Tests
- Use Verify (Verify.Xunit) or Snapshooter to capture GuessResultDto patterns
- Store snapshots under
Codel-Cloud-Native.Tests/__snapshots__
- Persistence (if implemented) Integration-lite
- Spin up test container for Redis (or in-memory substitute) - optional initial
- Round-trip session save/load
- Test Utilities
- Builder / factory helpers for GameSession, Guess
- Random word generator stub for deterministic tests
- CI Readiness
- Category/Trait attributes:
[Trait("Category","Integration")]for persistence + API tests - Default run excludes Integration unless
RunIntegration=trueenv var
- Category/Trait attributes:
Implementation Plan
- Add test helper classes (e.g.,
TestWordProvider,GameSessionBuilder) - Add evaluation edge case tests
- Introduce snapshot library + first snapshot for representative guess result
- Add minimal API tests (ensuring use of in-memory persistence fakes if Issue Feature: Add Game Session Persistence & Redis Caching Layer #9 not merged yet)
- Add Trait filtering logic in test project (Directory.Build.props or run script) to exclude integration by default
- Document how to run full suite in README
Acceptance Criteria
- Coverage increased for evaluator edge cases (qualitative; ensure new tests present)
- Snapshot tests pass and fail meaningfully on structure change
- API tests validate success + error ProblemDetails JSON
- Integration tests skipped by default unless enabled
Non-Goals
- Full load / performance testing
- Browser end-to-end tests
Risks & Mitigation
- Snapshot churn -> Keep snapshots narrow (only essential fields)
Definition of Done
Merged PR with new tests, snapshots committed, README updated with test running instructions.
Estimated Effort
Small-Medium (3-5h).
Depends on: Issue #8 (domain abstractions), optionally Issue #11 (ProblemDetails shapes).
Metadata
Metadata
Assignees
Labels
No labels