What is shift-left testing, and how do you apply it in a pipeline?

IntermediateConceptTesting in DevOps
Answer

In one line: Shift-left testing means running tests as early as possible — on the developer's machine and in every pull request — instead of waiting for a testing phase at the end, so bugs are found when they're cheapest to fix.

Where tests run in a shift-left pipeline:

  1. In the IDE — linters, type checks and unit tests while coding.
  2. Pre-commit hooks — formatting, secret scanning (Gitleaks), quick unit tests before code leaves the laptop.
  3. Pull request CI — unit tests, integration tests with Testcontainers, static analysis (SonarQube), dependency and IaC scans, contract tests.
  4. Preview environments — test the running change before merging.
  5. After merge — integration/E2E in staging, performance tests.

Example pre-commit config:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.18.0
    hooks: [{ id: gitleaks }]
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.86.0
    hooks: [{ id: terraform_fmt }, { id: terraform_validate }]

What changes for people:

  • Developers own testing for their code, not just the QA team.
  • QA engineers become quality coaches and automation experts, building test frameworks and doing exploratory testing.
  • Testing becomes part of the Definition of Done.

Benefits: cheaper fixes, faster feedback, fewer surprises at release time, and safer frequent deployments.

Balance with shift-right: some problems only show up with real traffic, so also use canaries, monitoring and synthetic checks in production.

Tip for interviews: describe the specific checks you added at each stage — "pre-commit, PR, post-merge, production" is a clear structure.

All DevOps Fundamentals questions

More on Testing in DevOps