You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

step-02-identify-targets.md 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ---
  2. name: 'step-02-identify-targets'
  3. description: 'Identify automation targets and create coverage plan'
  4. outputFile: '{test_artifacts}/automation-summary.md'
  5. nextStepFile: '{skill-root}/steps-c/step-03-generate-tests.md'
  6. ---
  7. # Step 2: Identify Automation Targets
  8. ## STEP GOAL
  9. Determine what needs to be tested and select appropriate test levels and priorities.
  10. ## MANDATORY EXECUTION RULES
  11. - 📖 Read the entire step file before acting
  12. - ✅ Speak in `{communication_language}`
  13. - 🚫 Avoid duplicate coverage across test levels
  14. ---
  15. ## EXECUTION PROTOCOLS:
  16. - 🎯 Follow the MANDATORY SEQUENCE exactly
  17. - 💾 Record outputs before proceeding
  18. - 📖 Load the next step only when instructed
  19. ## CONTEXT BOUNDARIES:
  20. - Available context: config, loaded artifacts, and knowledge fragments
  21. - Focus: this step's goal only
  22. - Limits: do not execute future steps
  23. - Dependencies: prior steps' outputs (if any)
  24. ## MANDATORY SEQUENCE
  25. **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
  26. ## 1. Determine Targets
  27. **BMad-Integrated:**
  28. - Map acceptance criteria to test scenarios
  29. - Check for existing ATDD outputs to avoid duplication
  30. - Expand coverage with edge cases and negative paths
  31. **Standalone:**
  32. - If specific target feature/files are provided, focus there
  33. - Otherwise auto-discover features in `{source_dir}`
  34. - Prioritize critical paths, integrations, and untested logic
  35. **If {detected_stack} is `frontend` or `fullstack`:**
  36. **Browser Exploration (if `tea_browser_automation` is `cli` or `auto`):**
  37. > **Fallback:** If CLI is not installed, fall back to MCP (if available) or skip browser exploration and rely on code/doc analysis.
  38. Use CLI to explore the application and identify testable pages/flows:
  39. 1. `playwright-cli -s=tea-automate open <target_url>`
  40. 2. `playwright-cli -s=tea-automate snapshot` → capture page structure and element refs
  41. 3. Analyze snapshot output to identify testable elements and flows
  42. 4. `playwright-cli -s=tea-automate close`
  43. > **Session Hygiene:** Always close sessions using `playwright-cli -s=tea-automate close`. Do NOT use `close-all` — it kills every session on the machine and breaks parallel execution.
  44. **If {detected_stack} is `backend` or `fullstack`:**
  45. **Source & API Analysis (no browser exploration):**
  46. - Scan source code for route handlers, controllers, service classes, and public APIs
  47. - Read OpenAPI/Swagger specs (`openapi.yaml`, `swagger.json`) if available
  48. - Identify database models, migrations, and data access patterns
  49. - Map service-to-service integrations and message queue consumers/producers
  50. - Check for existing contract tests (Pact, etc.)
  51. ---
  52. **If `use_pactjs_utils` is enabled — Provider Endpoint Mapping (all stacks):**
  53. When consumer-driven contract tests will be generated, build a Provider Endpoint Map during target identification. This applies to all `{detected_stack}` values — frontend, backend, and fullstack consumers all need provider scrutiny.
  54. 1. **Locate provider source and/or OpenAPI spec**: Scan workspace for provider project (from config, monorepo structure, or adjacent repositories). Also check for OpenAPI/Swagger spec files (`openapi.yaml`, `openapi.json`, `swagger.json`) — these document the provider's contract explicitly and can supplement or replace handler code analysis.
  55. 2. **Map each consumer endpoint** to its provider counterpart:
  56. - Provider file path (route handler)
  57. - Route pattern (METHOD + path)
  58. - Validation schema location (Joi, Zod, class-validator) or OpenAPI request schema
  59. - Response type/DTO definition location or OpenAPI response schema
  60. - OpenAPI spec path (if available, e.g., `server/openapi.yaml`)
  61. 3. **Output as "Provider Endpoint Map" table** in the coverage plan:
  62. ```markdown
  63. | Consumer Endpoint | Provider File | Route | Validation Schema | Response Type | OpenAPI Spec |
  64. | --------------------- | --------------------------------- | ------------------------- | ----------------------------------- | --------------- | ------------------------------------------------- |
  65. | GET /api/v2/users/:id | server/src/routes/userHandlers.ts | GET /api/v2/users/:userId | server/src/validation/user.ts | UserResponseDto | server/openapi.yaml#/paths/~1api~1v2~1users~1{id} |
  66. | POST /api/v2/users | server/src/routes/userHandlers.ts | POST /api/v2/users | server/src/validation/createUser.ts | UserResponseDto | server/openapi.yaml#/paths/~1api~1v2~1users |
  67. ```
  68. 4. **If provider source not accessible**: Mark entries with `TODO — provider source not accessible` and note in coverage plan that provider scrutiny will use graceful degradation (see `contract-testing.md` Provider Scrutiny Protocol)
  69. ---
  70. ## 2. Choose Test Levels
  71. Use `test-levels-framework.md` to select:
  72. - **E2E** for critical user journeys
  73. - **API** for business logic and service contracts
  74. - **Component** for UI behavior
  75. - **Unit** for pure logic and edge cases
  76. ---
  77. ## 3. Assign Priorities
  78. Use `test-priorities-matrix.md`:
  79. - P0: Critical path + high risk
  80. - P1: Important flows + medium/high risk
  81. - P2: Secondary + edge cases
  82. - P3: Optional/rare scenarios
  83. ---
  84. ## 4. Coverage Plan
  85. Produce a concise coverage plan:
  86. - Targets by test level
  87. - Priority assignments
  88. - Justification for coverage scope (critical-paths/comprehensive/selective)
  89. ---
  90. ## 5. Save Progress
  91. **Save this step's accumulated work to `{outputFile}`.**
  92. - **If `{outputFile}` does not exist** (first save), create it with YAML frontmatter:
  93. ```yaml
  94. ---
  95. stepsCompleted: ['step-02-identify-targets']
  96. lastStep: 'step-02-identify-targets'
  97. lastSaved: '{date}'
  98. ---
  99. ```
  100. Then write this step's output below the frontmatter.
  101. - **If `{outputFile}` already exists**, update:
  102. - Add `'step-02-identify-targets'` to `stepsCompleted` array (only if not already present)
  103. - Set `lastStep: 'step-02-identify-targets'`
  104. - Set `lastSaved: '{date}'`
  105. - Append this step's output to the appropriate section.
  106. Load next step: `{nextStepFile}`
  107. ## 🚨 SYSTEM SUCCESS/FAILURE METRICS:
  108. ### ✅ SUCCESS:
  109. - Step completed in full with required outputs
  110. ### ❌ SYSTEM FAILURE:
  111. - Skipped sequence steps or missing outputs
  112. **Master Rule:** Skipping steps is FORBIDDEN.