Move testing activities earlier in the development lifecycle to catch defects when they're cheapest to fix. Use when implementing TDD, CI/CD, or early quality practices.
Instrucciones de origen · Vista previa de solo lectura
name
shift-left-testing
description
Move testing activities earlier in the development lifecycle to catch defects when they're cheapest to fix. Use when implementing TDD, CI/CD, or early quality practices.
# CI pipeline - tests run on every commitname:CIon: [push, pull_request]
jobs:test:runs-on:ubuntu-lateststeps:-uses:actions/checkout@v4-run:npmci-run:npmruntest:unit-run:npmruntest:integration-run:npmrunlintquality-gate:needs:teststeps:-name:CoverageCheckrun:npxcoverage-check--min80-name:NoNewWarningsrun:npmrunlint----max-warnings0
Level 2: TDD Practice
// Red: Write failing test firsttest('calculates discount for orders over $100', () => {
const order = newOrder([{ price: 150 }]);
expect(order.discount).toBe(15); // 10% off
});
// Green: Minimal implementationclassOrder {
getdiscount() {
returnthis.total > 100 ? this.total * 0.1 : 0;
}
}
// Refactor: Improve while keeping green
Level 3: BDD in Refinement
# Example mapping before coding
Feature: Loyalty Discount
Scenario: Gold member gets 15% discount
Given a customer with "gold" membership
When they checkout with $200 in cart
Then discount applied is $30
And order total is $170
Scenario: New customer gets no discount
Given a customer with no membership
When they checkout with $200 in cart
Then no discount is applied
Level 4: Risk Analysis in Design
// During architecture reviewawaitTask("Risk Analysis", {
phase: 'design',
component: 'payment-service',
questions: [
'What happens when payment gateway times out?',
'How do we handle duplicate submissions?',
'What if inventory changed during checkout?'
]
}, "qe-requirements-validator");
// Output: Testability requirements, failure mode tests
Earlier = Cheaper. Requirements defects cost 1x; production defects cost 100x. Test pyramid: 70% unit, 20% integration, 10% E2E. Every commit runs tests. TDD builds quality in.
With Agents: Agents validate requirements testability, generate tests from specs, and select optimal regression suites. Use agents to implement shift-left practices consistently.