shift-left-testing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Shift-Left Testing

左移测试

<default_to_action> When implementing early testing practices:
  1. VALIDATE requirements before coding (testability, BDD scenarios)
  2. WRITE tests before implementation (TDD)
  3. AUTOMATE in CI pipeline (every commit triggers tests)
  4. 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> 在实施早期测试实践时:
  1. 在编码前验证需求(可测试性、BDD场景)
  2. 在实现前编写测试(TDD)
  3. 在CI流水线中实现自动化(每次提交触发测试)
  4. 立即修复缺陷——绝不要让缺陷累积
快速左移层级:
  • 层级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

左移层级

LevelPracticeWhen
1Unit tests in PRBefore merge
2TDDBefore implementation
3BDD/Example MappingDuring refinement
4Risk AnalysisDuring design

层级实践内容时机
1PR中包含单元测试合并前
2TDD实现前
3BDD/示例映射需求细化阶段
4风险分析设计阶段

Level 1: Tests in Every PR

层级1:每个PR都包含测试

yaml
undefined
yaml
undefined

CI 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 history
aqe/shift-left/
├── requirements/*       - Validated requirements
├── generated-tests/*    - Auto-generated tests
├── coverage-targets/*   - Coverage goals by component
└── pipeline-results/*   - CI/CD test history

Fleet 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
    /tdd-london-chicago
    for specific TDD guidance
  • Generate tests → Use
    /qe-test-generation
    for AI-powered test generation
  • CI/CD quality → Use
    /cicd-pipeline-qe-orchestrator
    for pipeline setup
  • TDD实践 → 参考
    /tdd-london-chicago
    获取具体TDD指导
  • 生成测试 → 使用
    /qe-test-generation
    进行AI驱动的测试生成
  • 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阶段
  • 在没有轻量环境的情况下进行左移,只会转移瓶颈——先解决环境问题