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:
- In the IDE — linters, type checks and unit tests while coding.
- Pre-commit hooks — formatting, secret scanning (Gitleaks), quick unit tests before code leaves the laptop.
- Pull request CI — unit tests, integration tests with Testcontainers, static analysis (SonarQube), dependency and IaC scans, contract tests.
- Preview environments — test the running change before merging.
- 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.
More on Testing in DevOps
What is the testing pyramid?BeginnerWhat is the difference between unit, integration and end-to-end tests?BeginnerWhat are smoke tests and sanity tests?BeginnerWhat is regression testing?BeginnerWhat is test automation, and what should (and shouldn't) be automated?BeginnerWhat is contract testing, and why is it useful for microservices?Intermediate