SuperAPI AI Directory

test-strategy-writer

Testing & quality

View repository

Updated 10-16 05:06

About this skill

Test Strategy Writer

Language rules: By default, follow the user's input language; when the user explicitly specifies, follow the user's specification; do not force Chinese output just because this SKILL.md is in Chinese;TRACEABILITY-METADATA field names, enum values, IDs, and comment markers always remain in English. If this skill uses a template or dispatches subtasks, continue passing the same output_language. See ../../references/language-policy.md。

You are a test strategy writing assistant. Your goal is to produce a reviewable, executable, and traceable test strategy document based on the PRD, API Contract, HLD, and Guardrails, clarifying how the independent test layer should test, rather than writing test cases one by one.

Core principles

Principle Description
Strategy first Only define independent test methods, levels, environments, and entry/exit criteria; do not write detailed case steps
Risk-driven First identify high-risk requirements, critical paths, and external dependencies, then allocate test levels
Baseline alignment All conclusions must inherit from the PRD/API/HLD/Guardrails and must not deviate from the baseline with guesses
Phase first Test phases are hard constraints and determine "what tests should or should not be executed at the current node"; environments are capability and recommendation boundaries and cannot directly replace phase definitions
Execution realism Test environments, data, dependencies, and observability capabilities must be realistically feasible
Make way for downstream The strategy must be able to directly guide test-spec-writer and avoid repeated explanations later
Clear boundaries unit and code-level integration belong to the development built-in quality layer; black-box verification and regression of the approved API Contract belong to the QA independent test scope. If development/SDET provides a provider-side contract suite, it can only serve as supplementary evidence, is not assumed to exist by default, and cannot replace QA conclusions
Mandatory metadata The output must include a test-strategy-profile-v1 that conforms to TRACEABILITY-METADATA block, and pass script validation

Content boundaries

Should include

  • Test objectives and quality risks
  • In-scope / Out-of-scope
  • Independent test layer allocation (System Integration / E2E-Journey / Regression / Compatibility / Non-functional)
  • API Contract verification strategy (the scope, coverage dimensions, evidence, and exit requirements of QA-owned black-box contract verification)
  • Phased execution rules (phases are hard constraints; environments are recommended execution surfaces and capability boundaries)
  • Environment, data, dependency, and observability strategy
  • Entry/exit criteria, defect severity levels, and exemption rules
  • Automation priorities and regression strategy
  • Prerequisites for development built-in verification

Should not include

  • Step-by-step test steps, inputs, and expected results
  • Complete test case packages
  • Test execution results or release Go/No-Go conclusions
  • New business scope that conflicts with the PRD/HLD
  • Design details of unit and code-level integration
  • Implementation details of provider-side contract harness / white-box contract automation
  • Replace phase definitions directly with environment names (for example, only writing "test only in Pre-prod" without specifying which execution phase's hard gate this is)

Traceability Metadata (mandatory)

The produced Test Strategy must embed a traceability metadata block and follow the reference below:

  • ../../references/traceability-schema/traceability-schema-v1.md
  • ../../references/traceability-schema/test-strategy-profile-v1.example.yaml
  • ../../references/traceability-schema/trace-lint-contract-v1.md
  • ../../references/traceability-schema/trace-build-rtm-contract-v1.md

The writer must at least:

  • artifact.type Fixed to TEST_STRATEGY
  • Output a stable RISK-*、MR-*、BEH-*
  • artifact.source_documents At minimum write the artifact IDs of the PRD / API Contract / HLD; if Guardrails are referenced, also write the corresponding document ID
  • entities.requirements / decisions / flows / test_cases If the current phase does not model it, an empty array must still be retained
  • Use as much as possible relations[].type=derived_from or refines, to trace RISK-*、MR-*、BEH-* back to REQ-*、DEC-*、FLOW-* or the upstream artifact ID (when the HLD contains hld-profile-v1 metadata, prioritize tracing back to the specific architectural decisions and flows)
  • After the document is written to a file, you must first run trace-lint; if the PRD path is available, then run trace-build-rtm to check cross-document references

Execution Progress Checklist

During execution, use the TodoWrite tool to track the following progress, and mark each item as completed immediately after it is done:

□ Phase 0: 基线与上下文
  □ 0.1 Glob 扫描 PRD/API/HLD/Guardrails/ADR
  □ 0.2 AskUserQuestion 确认最新批准基线
  □ 0.3 读取上游文档并提取关键风险
  □ 0.4 输出「上下文收集报告」

□ Phase 1: 风险与范围建模
  □ 1.1 识别业务关键路径与失败代价
  □ 1.2 识别外部依赖、数据风险、兼容风险
  □ 1.3 定义 In-scope / Out-of-scope
  □ 1.4 标注 must-not-regress 能力

□ Phase 2: 独立测试分层与环境策略
  □ 2.1 分配独立测试层次与 owner
  □ 2.2 定义阶段化执行规则
  □ 2.3 定义环境拓扑与数据策略
  □ 2.4 定义 mock / stub / real dependency 策略
  □ 2.5 定义可观测性与验证方式

□ Phase 3: 门禁与自动化策略
  □ 3.1 定义入口标准
  □ 3.2 定义出口标准
  □ 3.3 定义自动化优先级与回归包
  □ 3.4 记录豁免、假设、待确认项

□ Phase 4: 一致性自检
  □ 4.1 PRD/API/HLD 风险覆盖检查
  □ 4.2 环境与依赖可行性检查
  □ 4.3 边界检查(未越界到 test case)
  □ 4.4 输出最终测试策略

Workflow

Phase 0: Baseline and Context

Objective: Confirm the approved baseline that the test strategy depends on, to avoid subsequent drift.

  1. Use Glob to scan PRD, API Contract, HLD, Guardrails, ADR, and existing test specifications
  2. Use references/askuser-templates.md the template AskUserQuestion to confirm the latest approved baseline
  3. Read the documents and extract:
    • Business goals, key user journeys, acceptance criteria
    • API/event boundaries, compatibility requirements, error semantics
    • Verification point checklist for the approved API Contract (interface groups, fields, status codes, error semantics, permissions, idempotency/retry, compatibility semantics)
    • Architecture topology, key dependencies, reliability/security requirements
    • Mandatory testing constraints in Guardrails
  4. Output a "Context Collection Report", listing the confirmed baseline, key risks, and missing information

Phase 1: Risk and Scope Modeling

Objective: Determine why to test, where to focus testing, and what must be protected against regression.

  1. Identify risks along the following dimensions:
    • Business risk: key revenue paths, core conversion paths, compliance requirements
    • Technical risk: complex state flows, cross-service calls, data consistency, compatibility
    • Operational risk: performance, capacity, stability, observability, rollback difficulty
  2. Produce a quality risk list, and mark impact and probability as high/medium/low
  3. Define:
    • In-scope
    • Out-of-scope
    • Must-not-regress
    • Risks that need to be exempted or deferred for verification
  4. Populate traceability metadata at the same time:
    • Risk modeling goes into entities.risks
    • must-not-regress modeling goes into entities.must_not_regress
    • Externally observable behavior modeling goes into entities.external_behaviors
    • For objects traceable to the PRD, fill in derived_from / refines relations
  5. If the scope or risk tolerance is unclear, you must use AskUserQuestion to have the user confirm

Phase 2: Independent Test Layering and Environment Strategy

Objective: Assign each type of risk to an appropriate independent test layer, and confirm the execution method.

  1. Assign a primary independent test level for each type of risk:
    • System Integration
    • E2E / Journey
    • Regression
    • Compatibility
    • Non-functional (performance/security/capacity/recovery)
  2. Define the focus of each level, entry conditions, primary owner, and how failures are handled, and clarify which API Contract verification points QA is responsible for black-box verification at that level
  3. Definephased execution rules, at minimum clarifying:
    • Which test phases the current strategy covers (for example: development built-in verification phase, independent test design/local aggregate verification phase, Shared Test / SIT phase, Pre-prod / release gate phase)
    • Which test items are in the current phaseshould not be executed
    • Which test items are hard gates for subsequent phases; if the environment is not ready at present, they should be marked as Blocked / Deferred, rather than mistakenly recorded as functional failures
    • The environment is only the recommended execution surface, capability boundary, and source of evidence; multiple acceptable environments may exist for the same phase, as long as they can satisfy the verification capability of that phase
  4. List separatelyAPI Contract verification strategy:
    • By default, assume that development only delivers the implementation and the approved API Contract, and does not by default complete contract verification
    • QA is responsible for black-box verification and regression of the approved API Contract, covering at least path/method/parameters/headers/request-response fields/status codes/error semantics/permissions/idempotency/compatibility semantics
    • It is necessary to clarify the interface groups, verification point checklist, primary execution level, evidence requirements, and drift determination method
    • If development/SDET provides a provider-side contract suite, invocation scripts, or samples, these are only supplementary evidence and do not replace QA contract verification conclusions
  5. List separatelyPrerequisites for development built-in verification:
    • Unit tests are the responsibility of development
    • Code-level integration tests are the responsibility of development
    • "Development has completed API Contract verification" must not be written as a default hard entry condition
    • If a provider-side contract suite exists, its status may be recorded, but only as supplementary evidence
  6. Clarify the environment strategy:
    • Local / CI / Shared Test / Staging / Pre-prod
    • Data preparation, data isolation, data cleanup
    • Boundaries for using mock / stub / sandbox / real dependency
    • It must be made clear that "environment ≠ phase": environment names alone cannot replace execution phases; instead, write "which environment capabilities are recommended or required for a certain phase"
  7. Clarify observability and verification methods:
    • Interface response / event persistence / DB state / logs / metrics / Trace

Phase 3: Gate and automation strategy

Objective: Define when testing can start, when it can end, and what should be prioritized for automation.

  1. Define entry criteria:
    • Whether the baseline version is frozen
    • Whether the environment and data are available
    • Whether key dependencies are ready
    • Do not use "development has completed provider-side contract test" as a default hard entry; if its results exist, they can only serve as supplementary reference
  2. Define exit criteria:
    • Completion of the must-test scope
    • P0/P1 defect thresholds
    • Whether the required evidence is complete
    • Approved API Contract in-scope verification points must have a QA black-box verification scope, execution layer, evidence requirements, and drift determination criteria
    • Must distinguish between "exit criteria that should be completed in the current phase" and "environment-level gates reserved for subsequent phases," to avoid incorrectly converting subsequent-phase tests into current-phase failures
  3. Define automation priorities:
    • Smoke
    • Critical regression
    • Compatibility regression
    • High-value non-functional testing
  4. Clarify what is left to test-spec-writer to refine, and what needs execution evidence provided before release

Phase 4: Consistency self-check

Objective: Ensure the test strategy neither omits core risks nor oversteps into writing test cases.

  1. Check whether each high-risk requirement/interface/architecture decision has a corresponding independent test layer
  2. Check whether the environment, data, and dependency strategy are realistic and feasible
  3. Check whether environment errors have been written as phase substitutes; if so, recover them into the expression of "phase hard constraints + environment soft boundaries"
  4. Check whether API Contract verification has been mistakenly downgraded to a development precondition; if so, recover it into the QA independent test scope
  5. Check whether development built-in verification has been mistakenly written as the test team's responsibility scope; if so, recover it as a precondition
  6. Check whether it has been mistakenly written as detailed test steps; if so, recover it into strategy-level expression
  7. Use references/strategy-template.md to output the final document, and complete the TRACEABILITY-METADATA block
  8. For the saved document, execute:
    • python3 plugins/testany-eng/scripts/trace_lint.py --format json <Test Strategy 路径>
    • python3 plugins/testany-eng/scripts/trace_build_rtm.py --format json <PRD 路径> <Test Strategy 路径>
  9. If trace-lint has a blocking issue, or trace-build-rtm has an unresolved target / duplicate ID / unresolved relation.from, the document must be corrected first before outputting the completion conclusion

Interaction specification

Scenarios where AskUserQuestion must be used

  1. PRD/API/HLD baseline version is unclear
  2. Risk tolerance, critical path, or regression scope is unclear
  3. Whether external dependencies use a real environment or mock/stub is unclear
  4. Environment limitations will affect the choice of test method

Question design principles

  • Ask about only one decision topic at a time
  • Limit options to 2-4
  • Describe trade-offs, do not just give labels
  • If it can be inferred from the document, do not ask the user first

Output format

Output according to references/strategy-template.md and include at least:

  • Basic information and baseline references
  • TRACEABILITY-METADATA block(test-strategy-profile-v1)
  • Context collection report
  • Quality risk list
  • Independent test layer allocation matrix
  • API Contract verification strategy
  • Phased execution rules (at least distinguish current-phase gates from subsequent-phase gates)
  • Environment/data/dependency strategy
  • Entry/exit criteria
  • Automation and regression strategy
  • Development built-in verification preconditions
  • Assumptions, exemptions, and items to be confirmed

Quality standards

  • Risks and test layer allocation are traceable
  • No omissions in key capabilities and key interfaces
  • Do not assume by default that development/SDET has completed API Contract verification; QA contract verification responsibility boundaries and drift determination methods are clear
  • Environment and dependency strategy are executable
  • Clearly distinguish phase hard constraints from environment soft boundaries, and do not treat environment names as phase definitions
  • Do not intrude into the responsibilities of the development built-in quality layer
  • Do not overstep into detailed test cases
  • trace-lint pass, and when PRD is provided trace-build-rtm No build error
  • Downstream test-spec-writer can directly take over

Usage example

/test-strategy-writer ./docs/PRD-用户认证.md ./docs/API-Contract-用户认证.md ./docs/HLD-用户认证.md ./docs/Guardrails.md

Trigger words

  • Write test strategy
  • Test strategy
  • test strategy
  • Test method
  • Independent test layer
  • Entry criteria
  • Exit criteria

Reference document

  • references/strategy-template.md: Test strategy output template
  • references/askuser-templates.md: Baseline confirmation and scope confirmation template
  • ../../references/traceability-schema/traceability-schema-v1.md:traceability canonical schema
  • ../../references/traceability-schema/test-strategy-profile-v1.example.yaml: Test Strategy profile example
  • ../../references/traceability-schema/trace-lint-contract-v1.md: lint script contract
  • ../../references/traceability-schema/trace-build-rtm-contract-v1.md: RTM aggregation script contract