Files
2025-11-30 08:37:27 +08:00

3.9 KiB
Raw Permalink Blame History

Test Documentation

Last Updated: {{DATE}}


Overview

This directory contains all tests for the project, following the Story-Level Test Task Pattern where tests are consolidated in the final Story test task (NOT scattered across implementation tasks).

Test organization:

  • E2E tests (End-to-End) - 2-5 per Story - Priority ≥15 scenarios MUST be tested
  • Integration tests - 3-8 per Story - Multi-component interactions
  • Unit tests - 5-15 per Story - Individual component logic
  • Total: 10-28 tests per Story (Value-Based Testing)

Testing Philosophy

Test YOUR code, not frameworks. Focus on business logic and integration usage. Avoid testing database constraints, ORM internals, or framework validation.

Risk-based testing: Automate only Priority ≥15 scenarios (Business Impact × Probability). Test caps prevent bloat: 2-5 E2E, 3-8 Integration, 5-15 Unit (10-28 total per Story). No minimum limits - can be 0 if no high-priority scenarios exist.

Rule of thumb: If deleting your code wouldn't fail the test, you're testing someone else's code.

👉 Full strategy: See docs/reference/guides/testing-strategy.md


Test Structure

tests/
├── e2e/                        # End-to-End tests (2-5 per Story)
│   ├── auth/
│   ├── user-flows/
│   └── critical-paths/
├── integration/                # Integration tests (3-8 per Story)
│   ├── api/
│   ├── database/
│   └── services/
└── unit/                       # Unit tests (5-15 per Story)
    ├── components/
    ├── utils/
    └── services/

Story-Level Test Task Pattern

Rule: All tests (E2E/Integration/Unit) are written in the final Story test task (created by ln-350-story-test-planner after manual testing).

Why:

  • Single source of truth: All Story tests in one place
  • Atomic completion: Story Done when all tests pass
  • No scattered tests: NOT in implementation tasks
  • Regression prevention: Test suite runs before Story marked Done

Workflow:

  1. Implementation tasks completed → Manual testing → Bugs fixed
  2. ln-350-story-test-planner creates Story Finalizer test task
  3. ln-334-test-executor implements all tests (E2E/Integration/Unit) in final task
  4. All tests pass → Story marked Done

Test Execution

Run all tests:

npm test

Run specific test suites:

npm run test:unit           # Unit tests only
npm run test:integration    # Integration tests only
npm run test:e2e            # E2E tests only

Watch mode (development):

npm run test:watch

Quick Navigation


Maintenance

Update Triggers:

  • When adding new test directories or test suites
  • When changing test execution commands
  • When modifying Story-Level Test Task Pattern workflow

Verification:

  • All test directories exist (e2e/, integration/, unit/)
  • Test execution commands work correctly
  • SCOPE tags correctly define test documentation boundaries

Last Updated: {{DATE}}