shift-left-testing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShift-Left Testing
左移测试
<default_to_action>
When implementing early testing practices:
- VALIDATE requirements before coding (testability, BDD scenarios)
- WRITE tests before implementation (TDD)
- AUTOMATE in CI pipeline (every commit triggers tests)
- FIX defects immediately - never let them accumulate
Quick Shift-Left Levels:
- Level 1: Unit tests with each PR (developer responsibility)
- Level 2: TDD practice (tests before code)
- Level 3: BDD/Example mapping in refinement (requirements testing)
- Level 4: Risk analysis in design (architecture testing) </default_to_action>
<default_to_action>
在实施早期测试实践时:
- 在编码前验证需求(可测试性、BDD场景)
- 在实现前编写测试(TDD)
- 在CI流水线中实现自动化(每次提交触发测试)
- 立即修复缺陷——绝不要让缺陷累积
快速左移层级:
- 层级1:每个PR附带单元测试(开发者负责)
- 层级2:TDD实践(先写测试再写代码)
- 层级3:需求细化阶段的BDD/示例映射(需求测试)
- 层级4:设计阶段的风险分析(架构测试) </default_to_action>
Quick Reference Card
快速参考卡片
When to Use
适用场景
- Reducing cost of defects
- Implementing CI/CD pipelines
- Starting TDD practice
- Improving requirements quality
- 降低缺陷修复成本
- 实施CI/CD流水线
- 开始TDD实践
- 提升需求质量
Shift-Left Levels
左移层级
| Level | Practice | When |
|---|---|---|
| 1 | Unit tests in PR | Before merge |
| 2 | TDD | Before implementation |
| 3 | BDD/Example Mapping | During refinement |
| 4 | Risk Analysis | During design |
| 层级 | 实践内容 | 时机 |
|---|---|---|
| 1 | PR中包含单元测试 | 合并前 |
| 2 | TDD | 实现前 |
| 3 | BDD/示例映射 | 需求细化阶段 |
| 4 | 风险分析 | 设计阶段 |
Level 1: Tests in Every PR
层级1:每个PR都包含测试
yaml
undefinedyaml
undefinedCI pipeline - tests run on every commit
CI pipeline - tests run on every commit
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run test:unit
- run: npm run test:integration
- run: npm run lint
quality-gate:
needs: test
steps:
- name: Coverage Check
run: npx coverage-check --min 80
- name: No New Warnings
run: npm run lint -- --max-warnings 0
---name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run test:unit
- run: npm run test:integration
- run: npm run lint
quality-gate:
needs: test
steps:
- name: Coverage Check
run: npx coverage-check --min 80
- name: No New Warnings
run: npm run lint -- --max-warnings 0
---Agent-Assisted Shift-Left
Agent辅助左移测试
typescript
// Validate requirements testability
await Task("Requirements Validation", {
requirements: userStories,
check: ['INVEST-criteria', 'testability', 'ambiguity'],
generateBDD: true
}, "qe-requirements-validator");
// Generate tests from requirements
await Task("Generate Tests", {
source: 'requirements',
types: ['unit', 'integration', 'e2e'],
coverage: 'comprehensive'
}, "qe-test-generator");
// Smart test selection for changes
await Task("Select Regression Tests", {
changedFiles: prFiles,
algorithm: 'risk-based',
targetReduction: 0.7 // 70% time savings
}, "qe-regression-risk-analyzer");typescript
// Validate requirements testability
await Task("Requirements Validation", {
requirements: userStories,
check: ['INVEST-criteria', 'testability', 'ambiguity'],
generateBDD: true
}, "qe-requirements-validator");
// Generate tests from requirements
await Task("Generate Tests", {
source: 'requirements',
types: ['unit', 'integration', 'e2e'],
coverage: 'comprehensive'
}, "qe-test-generator");
// Smart test selection for changes
await Task("Select Regression Tests", {
changedFiles: prFiles,
algorithm: 'risk-based',
targetReduction: 0.7 // 70% time savings
}, "qe-regression-risk-analyzer");Agent Coordination Hints
Agent协调提示
Memory Namespace
内存命名空间
aqe/shift-left/
├── requirements/* - Validated requirements
├── generated-tests/* - Auto-generated tests
├── coverage-targets/* - Coverage goals by component
└── pipeline-results/* - CI/CD test historyaqe/shift-left/
├── requirements/* - Validated requirements
├── generated-tests/* - Auto-generated tests
├── coverage-targets/* - Coverage goals by component
└── pipeline-results/* - CI/CD test historyFleet Coordination
集群协调
typescript
const shiftLeftFleet = await FleetManager.coordinate({
strategy: 'shift-left',
agents: [
'qe-requirements-validator', // Level 3-4
'qe-test-generator', // Level 2
'qe-regression-risk-analyzer' // Smart selection
],
topology: 'sequential'
});typescript
const shiftLeftFleet = await FleetManager.coordinate({
strategy: 'shift-left',
agents: [
'qe-requirements-validator', // Level 3-4
'qe-test-generator', // Level 2
'qe-regression-risk-analyzer' // Smart selection
],
topology: 'sequential'
});Related Skills
相关技能
- tdd-london-chicago - TDD practices
- holistic-testing-pact - Proactive testing
- cicd-pipeline-qe-orchestrator - Pipeline integration
- shift-right-testing - Production feedback
- tdd-london-chicago - TDD实践
- holistic-testing-pact - 主动式测试
- cicd-pipeline-qe-orchestrator - 流水线集成
- shift-right-testing - 生产环境反馈
Remember
注意事项
With Agents: Agents validate requirements testability, generate tests from specs, and select optimal regression suites. Use agents to implement shift-left practices consistently.
借助Agent: Agent可验证需求的可测试性、根据规格生成测试,并选择最优的回归测试套件。使用Agent可确保左移实践的一致性实施。
Skill Composition
技能组合
- TDD practice → Use for specific TDD guidance
/tdd-london-chicago - Generate tests → Use for AI-powered test generation
/qe-test-generation - CI/CD quality → Use for pipeline setup
/cicd-pipeline-qe-orchestrator
- TDD实践 → 参考获取具体TDD指导
/tdd-london-chicago - 生成测试 → 使用进行AI驱动的测试生成
/qe-test-generation - CI/CD质量管控 → 使用进行流水线配置
/cicd-pipeline-qe-orchestrator
Gotchas
常见误区
- "Shift left" doesn't mean "only test left" — production monitoring (shift right) is still needed
- Agent generates tests before understanding requirements — tests for wrong behavior are worse than no tests
- CI pipeline tests that take >10 minutes kill the feedback loop — keep commit-stage tests under 5 minutes
- TDD discipline degrades when agent writes test+code simultaneously — enforce Red phase separation
- Shifting left without lightweight environments just shifts the bottleneck — fix environments first
- "左移"并不意味着"只在左侧测试"——生产环境监控(右移)仍然必不可少
- Agent在未理解需求的情况下生成测试——针对错误行为的测试比没有测试更糟
- CI流水线测试耗时超过10分钟会破坏反馈循环——确保提交阶段的测试耗时不超过5分钟
- 当Agent同时编写测试和代码时,TDD的规范性会下降——严格区分Red阶段
- 在没有轻量环境的情况下进行左移,只会转移瓶颈——先解决环境问题