ln-140-test-docs-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTest Documentation Creator
测试文档生成器
This skill creates and validates test documentation: testing-strategy.md (universal testing philosophy) + tests/README.md (test organization structure and Story-Level Test Task Pattern).
该技能用于创建和验证测试文档:testing-strategy.md(通用测试理念文档)+ tests/README.md(测试组织结构与Story-Level测试任务模式文档)。
When to Use This Skill
何时使用该技能
This skill is a L2 WORKER invoked by ln-100-documents-pipeline orchestrator.
This skill should be used directly when:
- Creating only test documentation (testing-strategy.md + tests/README.md)
- Validating existing test documentation structure and content
- Setting up test philosophy and structure documentation for existing project
- NOT creating full documentation structure (use ln-100-documents-pipeline for complete setup)
本技能是L2 WORKER,由ln-100-documents-pipeline编排器调用。
在以下场景可直接使用本技能:
- 仅需创建测试文档(testing-strategy.md + tests/README.md)
- 验证现有测试文档的结构与内容
- 为现有项目搭建测试理念与结构文档
- 无需创建完整文档结构(如需完整搭建,请使用ln-100-documents-pipeline)
How It Works
工作原理
The skill follows a 3-phase workflow: CREATE → VALIDATE STRUCTURE → VALIDATE CONTENT. Each phase builds on the previous, ensuring complete structure and semantic validation.
该技能遵循三阶段工作流:创建 → 结构验证 → 内容验证。每个阶段基于前一阶段的成果,确保文档结构完整且语义合规。
Phase 1: Create Test Documentation
阶段1:创建测试文档
Objective: Establish test philosophy and documentation structure.
Process:
1.1 Check & create directories:
- Check if exists → create if missing
docs/reference/guides/ - Check if exists → create if missing
tests/ - Check if exists → create if missing
tests/manual/ - Check if exists → create if missing
tests/manual/results/ - Add to project
tests/manual/results/if not present.gitignore - Log for each: "✓ Created [directory]/" or "✓ [directory]/ already exists"
1.2 Check & create documentation files:
-
Check ifexists
docs/reference/guides/testing-strategy.md -
If exists:
- Skip creation
- Log: "✓ testing-strategy.md already exists, proceeding to validation"
-
If NOT exists:
- Copy template: →
ln-114-test-docs-creator/references/testing_strategy_template.mddocs/reference/guides/testing-strategy.md - Replace placeholders:
- — current date (YYYY-MM-DD)
[CURRENT_DATE]
- Log: "✓ Created testing-strategy.md from template"
- Copy template:
-
Check ifexists
tests/README.md -
If exists:
- Skip creation
- Log: "✓ tests/README.md already exists, proceeding to validation"
-
If NOT exists:
- Copy template: →
ln-114-test-docs-creator/references/tests_readme_template.mdtests/README.md - Replace placeholders:
- — current date (YYYY-MM-DD)
{{DATE}}
- Log: "✓ Created tests/README.md from template"
- Copy template:
1.3 Output:
docs/reference/guides/
└── testing-strategy.md # Created or existing
tests/
├── README.md # Created or existing
└── manual/
└── results/ # Created, added to .gitignore目标:确立测试理念与文档结构。
流程:
1.1 检查并创建目录:
- 检查目录是否存在 → 不存在则创建
docs/reference/guides/ - 检查目录是否存在 → 不存在则创建
tests/ - 检查目录是否存在 → 不存在则创建
tests/manual/ - 检查目录是否存在 → 不存在则创建
tests/manual/results/ - 若项目中未包含
.gitignore,则添加该条目tests/manual/results/ - 为每个操作记录日志:"✓ 已创建[目录]/" 或 "✓ [目录]/ 已存在"
1.2 检查并创建文档文件:
-
检查是否存在
docs/reference/guides/testing-strategy.md -
若已存在:
- 跳过创建
- 记录日志:"✓ testing-strategy.md已存在,将进入验证环节"
-
若不存在:
- 复制模板:→
ln-114-test-docs-creator/references/testing_strategy_template.mddocs/reference/guides/testing-strategy.md - 替换占位符:
- — 当前日期(YYYY-MM-DD)
[CURRENT_DATE]
- 记录日志:"✓ 基于模板创建testing-strategy.md"
- 复制模板:
-
检查是否存在
tests/README.md -
若已存在:
- 跳过创建
- 记录日志:"✓ tests/README.md已存在,将进入验证环节"
-
若不存在:
- 复制模板:→
ln-114-test-docs-creator/references/tests_readme_template.mdtests/README.md - 替换占位符:
- — 当前日期(YYYY-MM-DD)
{{DATE}}
- 记录日志:"✓ 基于模板创建tests/README.md"
- 复制模板:
1.3 输出结构:
docs/reference/guides/
└── testing-strategy.md # 已创建或已存在
tests/
├── README.md # 已创建或已存在
└── manual/
└── results/ # 已创建,已添加至.gitignorePhase 2: Validate Structure
阶段2:结构验证
Objective: Ensure test documentation files comply with structural requirements and auto-fix violations.
Process:
2.1 Check SCOPE tags:
- Read both files (testing-strategy.md, tests/README.md) - first 5 lines only
- Check for tag in each
<!-- SCOPE: ... --> - Expected SCOPE tags:
- testing-strategy.md:
<!-- SCOPE: Universal testing philosophy (Risk-Based Testing, test pyramid, isolation patterns) --> - tests/README.md:
<!-- SCOPE: Test organization structure (directory layout, Story-Level Test Task Pattern) -->
- testing-strategy.md:
- If missing in either file:
- Use Edit tool to add SCOPE tag at line 1 (before first heading)
- Track violation:
scope_tags_added += 1
2.2 Check required sections:
- Load expected sections from
references/questions.md - For testing-strategy.md, required sections:
- "Testing Philosophy"
- "Test Levels"
- For tests/README.md, required sections:
- "Test Organization"
- "Running Tests"
- For each file:
- Read file content
- Check if header exists
## [Section Name] - If missing:
- Use Edit tool to add section with placeholder content from template
- Track violation:
missing_sections += 1
2.3 Check Maintenance section:
- For each file (testing-strategy.md, tests/README.md):
- Search for header
## Maintenance - If missing:
- Use Edit tool to add at end of file:
markdown
## Maintenance **Last Updated:** [current date] **Update Triggers:** - Test framework changes - Test organization changes - New test patterns introduced **Verification:** - [ ] All test examples follow current framework syntax - [ ] Directory structure matches actual tests/ - [ ] Test runner commands are current - Track violation:
maintenance_added += 1
- Use Edit tool to add at end of file:
- Search for
2.4 Check POSIX file endings:
- For each file:
- Check if file ends with single blank line (LF)
- If missing:
- Use Edit tool to add final newline
- Track fix:
posix_fixed += 1
2.5 Report validation:
- Log summary:
✅ Structure validation complete: - SCOPE tags: [added N / already present] - Missing sections: [added N sections] - Maintenance sections: [added N / already present] - POSIX endings: [fixed N / compliant] - If violations found: "⚠️ Auto-fixed [total] structural violations"
目标:确保测试文档符合结构要求,并自动修复违规问题。
流程:
2.1 检查SCOPE标签:
- 读取两个文件(testing-strategy.md、tests/README.md)的前5行内容
- 检查每个文件中是否包含标签
<!-- SCOPE: ... --> - 预期的SCOPE标签:
- testing-strategy.md:
<!-- SCOPE: Universal testing philosophy (Risk-Based Testing, test pyramid, isolation patterns) --> - tests/README.md:
<!-- SCOPE: Test organization structure (directory layout, Story-Level Test Task Pattern) -->
- testing-strategy.md:
- 若任一文件缺失该标签:
- 使用编辑工具在第1行(第一个标题前)添加SCOPE标签
- 记录违规情况:
scope_tags_added += 1
2.2 检查必填章节:
- 从加载预期章节列表
references/questions.md - 对于testing-strategy.md,必填章节:
- "Testing Philosophy"(测试理念)
- "Test Levels"(测试层级)
- 对于tests/README.md,必填章节:
- "Test Organization"(测试组织)
- "Running Tests"(运行测试)
- 针对每个文件:
- 读取文件内容
- 检查是否存在标题
## [章节名称] - 若缺失:
- 使用编辑工具添加包含模板占位符内容的章节
- 记录违规情况:
missing_sections += 1
2.3 检查维护章节:
- 针对每个文件(testing-strategy.md、tests/README.md):
- 搜索(维护)标题
## Maintenance - 若缺失:
- 使用编辑工具在文件末尾添加以下内容:
markdown
## 维护 **最后更新时间:** [当前日期] **更新触发条件:** - 测试框架变更 - 测试组织结构变更 - 引入新的测试模式 **验证项:** - [ ] 所有测试示例符合当前框架语法 - [ ] 目录结构与实际tests/目录匹配 - [ ] 测试运行器命令为最新版本 - 记录违规情况:
maintenance_added += 1
- 使用编辑工具在文件末尾添加以下内容:
- 搜索
2.4 检查POSIX文件结尾:
- 针对每个文件:
- 检查文件是否以单个空行(LF)结尾
- 若缺失:
- 使用编辑工具添加最终换行符
- 记录修复情况:
posix_fixed += 1
2.5 验证报告:
- 记录日志摘要:
✅ 结构验证完成: - SCOPE标签: [已添加N个 / 已存在] - 缺失章节: [已添加N个章节] - 维护章节: [已添加N个 / 已存在] - POSIX结尾: [已修复N个 / 合规] - 若发现违规:"⚠️ 已自动修复[总数]个结构违规问题"
Phase 3: Validate Content
阶段3:内容验证
Objective: Ensure each section answers its questions with meaningful content and populate test-specific sections from auto-discovery.
Process:
3.1 Load validation spec:
- Read
references/questions.md - Parse questions and validation heuristics for 4 sections (2 per file)
3.2 Validate testing-strategy.md sections:
For this file, use standard template content (no auto-discovery needed):
-
Testing Philosophy section:
- Read section content
- Check validation heuristics from questions.md:
- ✅ Mentions "Risk-Based Testing"
- ✅ Has test pyramid description
- ✅ Mentions priority threshold (≥15)
- ✅ References Story-Level Test Task Pattern
- ✅ Length > 100 words
- If ANY heuristic passes → content valid
- If ALL fail → log warning: "⚠️ testing-strategy.md → Testing Philosophy section may need review"
-
Test Levels section:
- Read section content
- Check validation heuristics from questions.md:
- ✅ Lists 3 levels (E2E, Integration, Unit)
- ✅ Has numeric ranges (2-5, 3-8, 5-15)
- ✅ Explains rationale
- ✅ Length > 150 words
- If ANY heuristic passes → content valid
- If ALL fail → log warning: "⚠️ testing-strategy.md → Test Levels section may need review"
Note: testing-strategy.md is universal philosophy - no project-specific auto-discovery needed.
3.3 Validate tests/README.md sections with auto-discovery:
Section: Test Organization
-
Auto-discover test framework:
- Check → "devDependencies" and "dependencies":
package.json- Node.js frameworks: jest, vitest, mocha, ava, tap, jasmine
- If found: Extract name and version
- Check (if Python project):
requirements.txt- Python frameworks: pytest, nose2, unittest2
- If found: Extract name and version
- Check (if Go project):
go.mod- Go uses built-in testing package
- If framework detected:
- Log: "✓ Test framework detected: [framework]@[version]"
- Track:
framework_detected = "[framework]"
- If NOT detected:
- Log: "⚠️ No test framework detected. Will use generic test organization."
- Track:
framework_detected = None
- Check
-
Auto-discover test directory structure:
- Use Glob tool to scan tests/ directory:
- Pattern:
"tests/e2e/**/*.{js,ts,py,go}" - Pattern:
"tests/integration/**/*.{js,ts,py,go}" - Pattern:
"tests/unit/**/*.{js,ts,py,go}"
- Pattern:
- Count files in each directory:
e2e_count = len(e2e_files)integration_count = len(integration_files)unit_count = len(unit_files)
- If directories exist:
- Log: "✓ Test structure: [e2e_count] E2E, [integration_count] Integration, [unit_count] Unit tests"
- If directories DON'T exist:
- Create placeholder structure:
tests/ e2e/ (empty, ready for E2E tests) integration/ (empty, ready for Integration tests) unit/ (empty, ready for Unit tests) - Log: "✓ Created test directory structure (will be populated during Story test task execution)"
- Create placeholder structure:
- Use Glob tool to scan tests/ directory:
-
Auto-discover naming conventions:
- For each test file found (from step 2):
- Extract filename pattern:
- → "*.test.js" convention
*.test.js - → "*.spec.ts" convention
*.spec.ts - → "test_*.py" convention
test_*.py - → "*_test.go" convention
*_test.go
- Extract filename pattern:
- Count occurrences of each pattern
- Use most common pattern (majority rule)
- If pattern detected:
- Log: "✓ Naming convention: [pattern] (detected from [count] files)"
- If NO files exist:
- Use framework default:
- Jest/Vitest → *.test.js
- Mocha → *.spec.js
- Pytest → test_*.py
- Go → *_test.go
- Log: "✓ Naming convention: [default_pattern] (framework default)"
- Use framework default:
- For each test file found (from step 2):
-
Check Test Organization section content:
- Read section from tests/README.md
- Check validation heuristics:
- ✅ Describes directory structure (e2e/integration/unit)
- ✅ Mentions naming conventions
- ✅ References Story-Level Test Task Pattern
- ✅ Has framework mention
- If ANY heuristic passes → content valid
- If ALL fail → log warning: "⚠️ tests/README.md → Test Organization section needs update"
Section: Running Tests
-
Auto-discover test runner command:
- Read → "scripts" → "test"
package.json - If found:
- Extract command value
- Examples:
- → Test runner: "npm test" (runs jest)
"jest" - → Test runner: "npm test" (runs vitest)
"vitest" - → Test runner: "npm test" (runs mocha)
"mocha" - Custom script → Test runner: "npm test" (runs [custom])
- Log: "✓ Test runner: npm test (runs [command])"
- If NOT found (no package.json or no test script):
- Use default based on detected framework (from step 3.3.1):
- Jest → "npm test"
- Vitest → "npm test"
- Pytest → "pytest"
- Go → "go test ./..."
- Log: "⚠️ No test script found in package.json. Using default '[command]'."
- Use default based on detected framework (from step 3.3.1):
- Read
-
Auto-discover coverage command (optional):
- Check → "scripts" for:
package.json- "test:coverage"
- "coverage"
- "test:cov"
- If found:
- Extract command
- Log: "✓ Coverage command: npm run [script_name]"
- If NOT found:
- Use framework default:
- Jest → "npm test -- --coverage"
- Vitest → "npm test -- --coverage"
- Pytest → "pytest --cov=src"
- Go → "go test -cover ./..."
- Log: "✓ Coverage command: [default] (framework default)"
- Use framework default:
- Check
-
Check Running Tests section content:
- Read section from tests/README.md
- Check validation heuristics:
- ✅ Has test runner command
- ✅ Mentions coverage
- ✅ Shows how to run specific tests
- ✅ Has command examples
- If ANY heuristic passes → content valid
- If ALL fail → log warning: "⚠️ tests/README.md → Running Tests section needs update"
3.4 Report content validation:
- Log summary:
✅ Content validation complete: - testing-strategy.md: [2 sections checked] - tests/README.md: [2 sections checked] - Test framework: [detected framework or "Not detected"] - Test structure: [e2e/integration/unit counts or "Created placeholder"] - Naming convention: [pattern or "Framework default"] - Test runner: [command] - Coverage command: [command]
目标:确保每个章节都包含有意义的内容以回应对应问题,并通过自动发现填充测试特定章节。
流程:
3.1 加载验证规范:
- 读取
references/questions.md - 解析4个章节(每个文件2个章节)对应的问题与验证规则
3.2 验证testing-strategy.md章节:
对于该文件,使用标准模板内容(无需自动发现):
-
测试理念章节:
- 读取章节内容
- 根据questions.md中的验证规则检查:
- ✅ 提及"Risk-Based Testing(基于风险的测试)"
- ✅ 包含测试金字塔描述
- ✅ 提及优先级阈值(≥15)
- ✅ 引用Story-Level测试任务模式
- ✅ 内容长度超过100词
- 若任意规则满足 → 内容有效
- 若所有规则都不满足 → 记录警告:"⚠️ testing-strategy.md → 测试理念章节可能需要审核"
-
测试层级章节:
- 读取章节内容
- 根据questions.md中的验证规则检查:
- ✅ 列出3个层级(E2E、集成、单元)
- ✅ 包含数值范围(2-5、3-8、5-15)
- ✅ 解释设计依据
- ✅ 内容长度超过150词
- 若任意规则满足 → 内容有效
- 若所有规则都不满足 → 记录警告:"⚠️ testing-strategy.md → 测试层级章节可能需要审核"
注意:testing-strategy.md是通用理念文档,无需项目特定的自动发现。
3.3 通过自动发现验证tests/README.md章节:
章节:测试组织
-
自动发现测试框架:
- 检查→ "devDependencies"与"dependencies":
package.json- Node.js框架:jest、vitest、mocha、ava、tap、jasmine
- 若找到:提取名称与版本
- 检查(若为Python项目):
requirements.txt- Python框架:pytest、nose2、unittest2
- 若找到:提取名称与版本
- 检查(若为Go项目):
go.mod- Go使用内置的testing包
- 若检测到框架:
- 记录日志:"✓ 检测到测试框架:[framework]@[version]"
- 记录:
framework_detected = "[framework]"
- 若未检测到:
- 记录日志:"⚠️ 未检测到测试框架,将使用通用测试组织结构"
- 记录:
framework_detected = None
- 检查
-
自动发现测试目录结构:
- 使用Glob工具扫描tests/目录:
- 匹配模式:
"tests/e2e/**/*.{js,ts,py,go}" - 匹配模式:
"tests/integration/**/*.{js,ts,py,go}" - 匹配模式:
"tests/unit/**/*.{js,ts,py,go}"
- 匹配模式:
- 统计每个目录下的文件数量:
e2e_count = len(e2e_files)integration_count = len(integration_files)unit_count = len(unit_files)
- 若目录已存在:
- 记录日志:"✓ 测试结构:[e2e_count]个E2E、[integration_count]个集成、[unit_count]个单元测试"
- 若目录不存在:
- 创建占位结构:
tests/ e2e/ (空目录,用于存放E2E测试) integration/ (空目录,用于存放集成测试) unit/ (空目录,用于存放单元测试) - 记录日志:"✓ 创建测试目录结构(将在Story测试任务执行时填充)"
- 创建占位结构:
- 使用Glob工具扫描tests/目录:
-
自动发现命名规范:
- 针对步骤2中找到的每个测试文件:
- 提取文件名模式:
- → "*.test.js"规范
*.test.js - → "*.spec.ts"规范
*.spec.ts - → "test_*.py"规范
test_*.py - → "*_test.go"规范
*_test.go
- 提取文件名模式:
- 统计每种模式的出现次数
- 使用最常见的模式(多数原则)
- 若检测到模式:
- 记录日志:"✓ 命名规范:[pattern](从[count]个文件中检测到)"
- 若不存在文件:
- 使用框架默认规范:
- Jest/Vitest → *.test.js
- Mocha → *.spec.js
- Pytest → test_*.py
- Go → *_test.go
- 记录日志:"✓ 命名规范:[default_pattern](框架默认)"
- 使用框架默认规范:
- 针对步骤2中找到的每个测试文件:
-
检查测试组织章节内容:
- 读取tests/README.md中的该章节
- 检查验证规则:
- ✅ 描述目录结构(e2e/integration/unit)
- ✅ 提及命名规范
- ✅ 引用Story-Level测试任务模式
- ✅ 提及测试框架
- 若任意规则满足 → 内容有效
- 若所有规则都不满足 → 记录警告:"⚠️ tests/README.md → 测试组织章节需要更新"
章节:运行测试
-
自动发现测试运行器命令:
- 读取→ "scripts" → "test"
package.json - 若找到:
- 提取命令值
- 示例:
- → 测试运行器:"npm test"(运行jest)
"jest" - → 测试运行器:"npm test"(运行vitest)
"vitest" - → 测试运行器:"npm test"(运行mocha)
"mocha" - 自定义脚本 → 测试运行器:"npm test"(运行[custom])
- 记录日志:"✓ 测试运行器:npm test(运行[command])"
- 若未找到(无package.json或无test脚本):
- 根据检测到的框架(来自步骤3.3.1)使用默认命令:
- Jest → "npm test"
- Vitest → "npm test"
- Pytest → "pytest"
- Go → "go test ./..."
- 记录日志:"⚠️ 在package.json中未找到测试脚本,将使用默认命令'[command]'"
- 根据检测到的框架(来自步骤3.3.1)使用默认命令:
- 读取
-
自动发现覆盖率命令(可选):
- 检查→ "scripts"中是否存在:
package.json- "test:coverage"
- "coverage"
- "test:cov"
- 若找到:
- 提取命令
- 记录日志:"✓ 覆盖率命令:npm run [script_name]"
- 若未找到:
- 使用框架默认命令:
- Jest → "npm test -- --coverage"
- Vitest → "npm test -- --coverage"
- Pytest → "pytest --cov=src"
- Go → "go test -cover ./..."
- 记录日志:"✓ 覆盖率命令:[default](框架默认)"
- 使用框架默认命令:
- 检查
-
检查运行测试章节内容:
- 读取tests/README.md中的该章节
- 检查验证规则:
- ✅ 包含测试运行器命令
- ✅ 提及覆盖率
- ✅ 说明如何运行特定测试
- ✅ 包含命令示例
- 若任意规则满足 → 内容有效
- 若所有规则都不满足 → 记录警告:"⚠️ tests/README.md → 运行测试章节需要更新"
3.4 内容验证报告:
- 记录日志摘要:
✅ 内容验证完成: - testing-strategy.md: [已检查2个章节] - tests/README.md: [已检查2个章节] - 测试框架: [检测到的框架或"未检测到"] - 测试结构: [e2e/integration/unit数量或"已创建占位结构"] - 命名规范: [模式或"框架默认"] - 测试运行器: [命令] - 覆盖率命令: [命令]
Complete Output Structure
完整输出结构
docs/reference/guides/
└── testing-strategy.md # Universal testing philosophy (465 lines)
tests/
└── README.md # Test organization + Story-Level Pattern (112 lines)Note: Actual test directories (e2e/, integration/, unit/) created during Story test task execution or Phase 3 if missing.
docs/reference/guides/
└── testing-strategy.md # 通用测试理念文档(465行)
tests/
└── README.md # 测试组织 + Story-Level模式文档(112行)注意:实际测试目录(e2e/、integration/、unit/)将在Story测试任务执行时创建,或在阶段3中若缺失则创建。
Reference Files Used
使用的参考文件
- Risk-based testing methodology:
shared/references/risk_based_testing.md
- 基于风险的测试方法论:
shared/references/risk_based_testing.md
Templates
模板文件
Testing Strategy Template:
- - Universal testing philosophy with:
references/testing_strategy_template.md- SCOPE tags (testing philosophy, NOT framework-specific)
- Core Philosophy ("Test YOUR code, not frameworks")
- Risk-Based Testing Strategy (Priority Matrix, test caps)
- Story-Level Testing Pattern
- Test Organization (E2E/Integration/Unit definitions)
- Isolation Patterns (Data Deletion/Transaction Rollback/DB Recreation)
- What To Test vs NOT Test (universal examples)
- Testing Patterns (Arrange-Act-Assert, Mock at the Seam, Test Data Builders)
- Common Issues (Flaky Tests, Slow Tests, Test Coupling)
- Coverage Guidelines
- Verification Checklist
Tests README Template:
- - Test organization with:
references/tests_readme_template.md- SCOPE tags (test documentation ONLY)
- Overview (E2E/Integration/Unit test organization)
- Testing Philosophy (brief, link to testing-strategy.md)
- Test Structure (directory tree)
- Story-Level Test Task Pattern (tests in final Story task, NOT scattered)
- Test Execution (project-specific commands)
- Quick Navigation (links to testing-strategy.md, kanban_board, guidelines)
- Maintenance section (Update Triggers, Verification, Last Updated)
Validation Specification:
- (v1.0.0) - Question-driven validation:
references/questions.md- Questions each section must answer (4 sections total)
- Validation heuristics (ANY passes → valid)
- Auto-discovery hints (test frameworks, directory structure, naming conventions)
- MCP Ref hints (external research if needed)
测试策略模板:
- - 通用测试理念模板,包含:
references/testing_strategy_template.md- SCOPE标签(测试理念,非框架特定)
- 核心理念("测试你的代码,而非框架")
- 基于风险的测试策略(优先级矩阵、测试上限)
- Story-Level测试模式
- 测试组织(E2E/集成/单元定义)
- 隔离模式(数据删除/事务回滚/数据库重建)
- 测试与非测试内容(通用示例)
- 测试模式(Arrange-Act-Assert、边界处Mock、测试数据构建器)
- 常见问题(不稳定测试、慢测试、测试耦合)
- 覆盖率指南
- 验证检查清单
测试README模板:
- - 测试组织模板,包含:
references/tests_readme_template.md- SCOPE标签(仅测试文档)
- 概述(E2E/集成/单元测试组织)
- 测试理念(简要说明,链接至testing-strategy.md)
- 测试结构(目录树)
- Story-Level测试任务模式(测试集中在最终Story任务中,而非分散)
- 测试执行(项目特定命令)
- 快速导航(链接至testing-strategy.md、kanban_board、指南)
- 维护章节(更新触发条件、验证项、最后更新时间)
验证规范:
- (v1.0.0)- 基于问题的验证:
references/questions.md- 每个章节必须回答的问题(共4个章节)
- 验证规则(任意规则满足即有效)
- 自动发现提示(测试框架、目录结构、命名规范)
- MCP参考提示(如需外部研究)
Best Practices
最佳实践
- No premature validation: Phase 1 creates structure, Phase 2 validates it (no duplicate checks)
- Parametric validation: Phase 3 validates 4 sections across 2 files (no code duplication)
- Auto-discovery first: Scan test frameworks and directory structure before using defaults
- Idempotent: ✅ Can run multiple times safely (checks existence before creation, re-validates on each run)
- Separation of concerns: CREATE → VALIDATE STRUCTURE → VALIDATE CONTENT
- Story-Level Test Task Pattern: Tests consolidated in final Story task (ln-510-test-planner creates task, ln-420-test-executor implements)
- Value-Based Testing: 2-5 E2E, 3-8 Integration, 5-15 Unit per Story (10-28 total max), Priority ≥15 MUST be tested
- No test code: This skill creates DOCUMENTATION only, NOT actual tests
- 无提前验证:阶段1创建结构,阶段2验证结构(无重复检查)
- 参数化验证:阶段3验证2个文件中的4个章节(无代码重复)
- 优先自动发现:先扫描测试框架与目录结构,再使用默认值
- 幂等性:✅ 可安全多次运行(创建前检查是否存在,每次运行重新验证)
- 关注点分离:创建 → 结构验证 → 内容验证
- Story-Level测试任务模式:测试集中在最终Story任务中(ln-510-test-planner创建任务,ln-420-test-executor执行)
- 基于价值的测试:每个Story包含2-5个E2E、3-8个集成、5-15个单元测试(总计最多10-28个),优先级≥15的内容必须测试
- 无测试代码:本技能仅创建文档,不生成实际测试代码
Documentation Standards
文档标准
- NO_CODE Rule: Test docs describe strategy, not test implementations
- Stack Adaptation: Framework commands must match project stack
- Format Priority: Tables (test levels, counts) > Lists > Text
- NO_CODE规则: 测试文档描述策略,而非测试实现
- 栈适配:框架命令必须与项目技术栈匹配
- 格式优先级:表格(测试层级、数量)> 列表 > 文本
Prerequisites
前置条件
Invoked by: ln-110-documents-pipeline orchestrator
Requires:
- directory (created by ln-112-reference-docs-creator or Phase 1 if missing)
docs/reference/guides/
Creates:
- (universal testing philosophy)
docs/reference/guides/testing-strategy.md - (test organization structure)
tests/README.md - Validated structure and content (auto-discovery of test frameworks and directory structure)
调用方: ln-110-documents-pipeline编排器
依赖:
- 目录(由ln-112-reference-docs-creator创建,或在阶段1中若缺失则创建)
docs/reference/guides/
创建的内容:
- (通用测试理念文档)
docs/reference/guides/testing-strategy.md - (测试组织结构文档)
tests/README.md - 经过验证的结构与内容(自动发现测试框架与目录结构)
Definition of Done
完成定义
Before completing work, verify ALL checkpoints:
✅ Structure Created (Phase 1):
- directory exists
docs/reference/guides/ - directory exists
tests/ - directory exists
tests/manual/ - directory exists
tests/manual/results/ - added to
tests/manual/results/.gitignore - exists (created or existing)
testing-strategy.md - exists (created or existing)
tests/README.md
✅ Structure Validated (Phase 2):
- SCOPE tags present in both files (first 5 lines)
- testing-strategy.md has "Testing Philosophy" and "Test Levels" sections
- tests/README.md has "Test Organization" and "Running Tests" sections
- Maintenance sections present in both files at end
- POSIX file endings compliant (LF, single blank line at EOF)
✅ Content Validated (Phase 3):
- testing-strategy.md → Testing Philosophy section checked (Risk-Based Testing mentioned)
- testing-strategy.md → Test Levels section checked (2-5 E2E, 3-8 Integration, 5-15 Unit)
- tests/README.md → Test Organization section checked or auto-discovered
- tests/README.md → Running Tests section checked or auto-discovered
- Test framework detected (if applicable) and logged
- Test directory structure scanned or created
- Naming conventions detected or defaults used
- Test runner command identified or defaults used
✅ Reporting:
- Phase 1 logged: creation summary
- Phase 2 logged: structural fixes (if any)
- Phase 3 logged: content validation summary with auto-discovery results
完成工作前,需验证所有检查点:
✅ 结构已创建(阶段1):
- 目录存在
docs/reference/guides/ - 目录存在
tests/ - 目录存在
tests/manual/ - 目录存在
tests/manual/results/ - 已添加至
tests/manual/results/.gitignore - 存在(已创建或已存在)
testing-strategy.md - 存在(已创建或已存在)
tests/README.md
✅ 结构已验证(阶段2):
- 两个文件中均存在SCOPE标签(前5行)
- testing-strategy.md包含"测试理念"与"测试层级"章节
- tests/README.md包含"测试组织"与"运行测试"章节
- 两个文件末尾均包含维护章节
- 符合POSIX文件结尾规范(LF,文件末尾单个空行)
✅ 内容已验证(阶段3):
- testing-strategy.md → 已检查测试理念章节(提及基于风险的测试)
- testing-strategy.md → 已检查测试层级章节(2-5个E2E、3-8个集成、5-15个单元)
- tests/README.md → 已检查或自动发现测试组织章节
- tests/README.md → 已检查或自动发现运行测试章节
- 已检测到测试框架(如适用)并记录
- 已扫描或创建测试目录结构
- 已检测到或使用默认命名规范
- 已识别或使用默认测试运行器命令
✅ 报告:
- 已记录阶段1:创建摘要
- 已记录阶段2:结构修复情况(如有)
- 已记录阶段3:内容验证摘要与自动发现结果
Technical Details
技术细节
Standards:
- Story-Level Test Task Pattern
- Value-Based Testing (2-5 E2E, 3-8 Integration, 5-15 Unit, 10-28 total max per Story)
- Risk-Based Testing (Priority ≥15)
Language: English only
Auto-Discovery Support:
- Node.js: jest, vitest, mocha, ava, tap, jasmine
- Python: pytest, nose2, unittest2
- Go: built-in testing package
Version: 7.2.0 (Added tests/manual/results/ structure creation and .gitignore entry)
Last Updated: 2026-01-15
标准:
- Story-Level测试任务模式
- 基于价值的测试(每个Story包含2-5个E2E、3-8个集成、5-15个单元,总计最多10-28个,优先级≥15的内容必须测试)
- 基于风险的测试(优先级≥15)
语言: 仅支持英文
自动发现支持:
- Node.js: jest, vitest, mocha, ava, tap, jasmine
- Python: pytest, nose2, unittest2
- Go: 内置testing包
版本: 7.2.0(新增tests/manual/results/结构创建与.gitignore条目)
最后更新时间: 2026-01-15