10 Automated Testing Stages in DevOps Pipelines

The 10 automated testing stages of a DevOps pipeline in order: where each runs, what it catches, what it blocks and how fast it should be.

Dec 10, 2025 - 17:22
Nov 5, 2026 - 10:31
 0  78
10 Automated Testing Stages in DevOps Pipelines

The 10 automated testing stages in a DevOps pipeline are pre-commit checks, static analysis, unit tests, dependency and secret scanning, build and image tests, integration tests, contract tests, end-to-end and acceptance tests, performance tests, and post-deployment verification. Order them from fastest and cheapest to slowest, so most defects fail the pipeline within minutes.

Tool lists tell you what to install. This guide answers a different question: where each test stage runs, what triggers it, what it should block, and how long it can take before developers start working around it. For the tools themselves, see our continuous testing tools roundup; for pass and fail thresholds, see CI/CD quality gates. Syntax examples were checked against official docs in November 2026.

Key takeaways

  • Each stage should answer one question and fail for one class of defect. Mixed stages produce failures nobody can read quickly.
  • Run the cheap stages on every push and pull request; run expensive suites on merge, nightly or before production.
  • The test pyramid still holds: many unit tests, fewer integration tests, a small number of end-to-end tests.
  • Contract tests let microservice teams catch breaking API changes without a full shared environment.
  • Testing does not end at deploy. Smoke tests and metric checks after release catch what staging could not.
  • Track flaky tests as defects. A suite people re-run until green stops protecting anything.

The 10 stages in pipeline order

#StageRuns onCatchesBlocks
1Pre-commit checksDeveloper machineFormatting, lint, obvious secretsThe commit (locally)
2Static analysis (SAST, lint, type checks)Every push / PRCode smells, insecure patterns, type errorsMerge
3Unit testsEvery push / PRLogic errors in functions and classesMerge
4Dependency and secret scanningEvery PR, plus scheduledKnown CVEs, leaked credentials, license issuesMerge
5Build and image testsEvery PRBroken builds, bad Dockerfiles, vulnerable base imagesMerge / publish
6Integration testsPR or mergeWrong queries, broken config, service wiringMerge or staging deploy
7Contract testsPR on consumer and providerBreaking API changes between servicesProvider deploy
8End-to-end and acceptance testsStaging after deployBroken user journeysProduction promotion
9Performance and DASTStaging, nightly or pre-releaseLatency regressions, runtime security issuesRelease (by threshold)
10Post-deployment verificationProductionErrors only real traffic or real config revealsTriggers rollback

Stage 1: pre-commit checks on the developer machine

The fastest feedback happens before code leaves the laptop. The pre-commit framework runs hooks from a config file in the repo:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
      - id: check-yaml
      - id: detect-private-key
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.18.4
    hooks:
      - id: gitleaks

Keep hooks to a few seconds. Developers can skip local hooks, so every check here must also run in CI. Treat this stage as a convenience, not a control.

Stage 2: static analysis

Linters, type checkers and SAST tools read source code without running it. Examples include ESLint, Pylint or Ruff, mypy, Semgrep, CodeQL and SonarQube. Run them on every pull request and report findings inline on the diff so reviewers see them in context.

A practical rule for existing codebases: fail only on new issues introduced by the change. Failing on years of old warnings on day one gets the stage switched off.

Stage 3: unit tests

Unit tests check small pieces of logic in isolation, with external calls replaced by fakes or mocks. They should run in minutes even for a large codebase. Publish results in JUnit XML so the CI tool can show which test failed and track history:

# GitLab CI/CD
unit_tests:
  stage: test
  script:
    - pytest --junitxml=report.xml --cov=app
  artifacts:
    when: always
    reports:
      junit: report.xml

Coverage is a useful signal of untested areas, but a coverage target alone encourages tests with no meaningful assertions. Review what tests assert, not only how many lines they touch.

Stage 4: dependency and secret scanning

Most application code comes from open-source packages. Software composition analysis (for example Dependabot alerts, Trivy, Grype, OWASP Dependency-Check or Snyk) compares your lock files with vulnerability databases. Secret scanners such as Gitleaks or your Git host's secret scanning look for credentials in commits.

Run these on pull requests and also on a schedule, because a new CVE can affect code that has not changed in months. Set a severity threshold for blocking and record accepted risks in the repository with an expiry date. Our DevSecOps tools by stage post compares the options.

Stage 5: build and image tests

A successful compile is a test in itself. For containers, add checks on the image you just built:

  • Lint the Dockerfile with Hadolint.
  • Scan the image for OS and library vulnerabilities (Trivy, Grype).
  • Run the container and hit its health endpoint before pushing it.
docker build -t web:$GIT_SHA .
trivy image --exit-code 1 --severity CRITICAL web:$GIT_SHA
docker run -d --name smoke -p 8080:8080 web:$GIT_SHA
sleep 5 && curl -fsS http://localhost:8080/healthz
docker rm -f smoke

Push the image only after these pass, and tag it with the commit SHA so later stages test exactly this artifact.

Stage 6: integration tests

Integration tests check that your code works with real dependencies: a database, a message broker, a cache. Testcontainers starts throwaway containers from test code, and CI services (GitLab services:, GitHub Actions services:) do the same at the job level.

# GitHub Actions job excerpt
services:
  postgres:
    image: postgres:16
    env:
      POSTGRES_PASSWORD: test
    ports:
      - 5432:5432
    options: >-
      --health-cmd pg_isready
      --health-interval 5s
      --health-retries 10

Each test should create and clean up its own data. Shared, long-lived test databases cause order-dependent failures that look like flakiness. API-level integration checks are covered in API testing tools for DevOps teams.

Stage 7: contract tests

When services are owned by different teams, a provider can break a consumer without either team's own tests failing. Consumer-driven contract testing (for example with Pact) works like this:

  1. The consumer's tests record the requests it makes and the responses it expects, producing a contract.
  2. The contract is published to a broker.
  3. The provider's pipeline replays those requests against the real provider and fails if a response no longer matches.
  4. Before deploy, a check confirms the version being released is compatible with what is running in that environment.

Contract tests replace much of the need for a large shared end-to-end environment, which is often slow and unstable.

Stage 8: end-to-end and acceptance tests

End-to-end tests drive the deployed application the way a user would, through a browser (Playwright, Cypress, Selenium) or through public APIs. They run after deploying to staging. Keep them to the critical journeys: sign in, search, checkout, the flows that make money or cause support calls. Large E2E suites are slow and fragile, and every flaky one erodes trust in the whole pipeline.

Acceptance tests written as business scenarios (for example in Gherkin with Cucumber) can sit here too, if product owners actually read and maintain them.

Stage 9: performance and dynamic security tests

Load testing tools such as k6, JMeter, Gatling or Locust measure latency and error rate under load. Run a short performance check on staging with thresholds that fail the build, and keep longer soak tests for nightly or pre-release runs:

// k6 options excerpt
thresholds: {
  http_req_duration: ['p(95)<500'],
  http_req_failed: ['rate<0.01'],
}

Dynamic application security testing (DAST) attacks the running app with tools such as OWASP ZAP. A baseline scan is fast enough for each staging deploy; full active scans belong in a scheduled job. Our guide to OWASP ZAP in CI/CD shows the setup.

Stage 10: post-deployment verification

Staging never matches production exactly. After each production deploy, run smoke tests against key endpoints, then watch error rate and latency for a set period. Canary releases make this automatic: tools such as Argo Rollouts or Flagger compare metrics for the new version against the old and roll back when thresholds are breached. Traffic mirroring is another option, covered in shadow deployment. A full checklist is in post-deployment validation steps.

Where each stage runs in the workflow

TriggerStagesTarget feedback time
Local commit1Seconds
Push / pull request2, 3, 4, 5, and fast parts of 6 and 7Short enough that developers wait for it, usually under about 10 to 15 minutes
Merge to mainFull 6, deploy to staging, 8, short 9Under an hour
Nightly / scheduledFull 9, scheduled 4Overnight
Production deploy10Minutes after release, then continuous

The time targets are common team guidelines, not standards. The point is that the stages run on every change must stay fast enough that nobody is tempted to skip them. Run independent jobs in parallel and split large suites across runners to keep within budget.

A pipeline skeleton with all the stages

This GitLab CI/CD outline shows how the stages fit together. Job scripts are placeholders; the structure, rules and ordering are the point.

stages: [static, test, build, integration, deploy_staging, verify_staging, deploy_prod, verify_prod]

lint_and_sast:
  stage: static
  script: [ruff check ., semgrep scan --error]

unit_tests:
  stage: test
  script: [pytest tests/unit --junitxml=unit.xml]
  artifacts: { reports: { junit: unit.xml }, when: always }

deps_and_secrets:
  stage: test
  script: [trivy fs --exit-code 1 --severity CRITICAL ., gitleaks detect]

build_image:
  stage: build
  script: [./ci/build_and_scan.sh]

integration_tests:
  stage: integration
  services: [postgres:16]
  script: [pytest tests/integration]

deploy_staging:
  stage: deploy_staging
  script: [./ci/deploy.sh staging]
  rules: [{ if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' }]

e2e_and_perf:
  stage: verify_staging
  script: [npx playwright test, k6 run perf/smoke.js]
  rules: [{ if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' }]

deploy_production:
  stage: deploy_prod
  environment: production
  script: [./ci/deploy.sh production]
  rules: [{ if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH', when: manual }]

smoke_production:
  stage: verify_prod
  script: [./ci/smoke.sh https://app.example.com]
  rules: [{ if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' }]

Merge requests run only the first four stages, which keeps feedback fast. The default branch runs everything, with a manual gate before production. Jobs in the same stage run in parallel, so linting, unit tests and scanning finish together.

Common mistakes

  • Testing a different artifact in each stage. Build once and promote the same image.
  • Automatic retries without reporting. They hide flaky tests that later hide real bugs.
  • Too many end-to-end tests. Push checks down to unit, integration and contract levels where possible.
  • Security scans that only warn. Set a blocking threshold for critical findings and an exception process.
  • No checks after release. A green pipeline does not prove production is healthy.

To build this kind of pipeline with guided labs, see our DevOps training or the security-focused DevSecOps course, both offered in Kharadi, Pune and live online.

Frequently asked questions

What are the main testing stages in a CI/CD pipeline?

Pre-commit checks, static analysis, unit tests, dependency and secret scanning, build and image tests, integration tests, contract tests, end-to-end tests, performance and DAST, and post-deployment verification. Order them from fastest to slowest.

What is the difference between integration and end-to-end tests?

Integration tests check that one component works with a real dependency such as a database. End-to-end tests drive the whole deployed system through its user interface or public API.

Where should security testing run in a pipeline?

In several places: SAST and secret scanning on every pull request, dependency and image scanning at build, DAST against staging, and scheduled scans for newly published CVEs.

How fast should CI tests be?

Fast enough that developers wait for results instead of switching tasks. Many teams aim for pull request feedback in roughly 10 to 15 minutes and move longer suites to merge or nightly runs.

What are contract tests used for?

They check that a service provider still meets the expectations its consumers recorded, so breaking API changes are caught in the provider's pipeline before deploy.

Should failed post-deployment checks roll back automatically?

For services with good metrics and canary releases, yes. Tools such as Argo Rollouts and Flagger compare the new version with the old and roll back when thresholds are breached.

How do you deal with flaky tests?

Track them as defects, quarantine them from blocking runs while they are fixed, and limit automatic retries. Common causes are shared test data, timing assumptions and external network calls.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.