Designing a Comprehensive Testing Strategy
This lesson explains the main test types and where each belongs in a pipeline.
Learning outcomes
After completing this lesson, you will be able to:
- Describe local, unit, integration and load tests.
- Explain the test pyramid.
- Place tests in pipeline stages.
- Configure fail criteria for Azure Load Testing.
Purpose of a strategy
Tests have a cost as well as a benefit. Each test takes time to write, time to run and time to maintain. A strategy aims for the greatest confidence with the fastest feedback, and that goal means catching each kind of defect at the earliest and cheapest point. This idea is called shifting left: moving checks towards the start of the delivery path.
Test types
Local tests
Local tests run on a developer's machine before a commit or push. They include unit tests, linters and pre-commit hooks. They give the fastest feedback, but they depend on developers running them, so pipelines must repeat important checks. Tools such as Testcontainers let developers run real dependencies, such as a database, in local containers.
Unit tests
Unit tests check a small piece of code in isolation, with dependencies replaced by test doubles. They run in milliseconds, need no environment and give precise failures, so they should form the largest group of tests. They run on every commit and pull request.
Integration tests
Integration tests check that components work together, such as code and a real database or a message queue. They find problems that mocks hide, like an incorrect SQL statement or a serialization mismatch. They are slower, and they may need a deployed environment or containers, which a pipeline can run as service containers.
Functional and end-to-end tests
End-to-end tests exercise a whole system as a user does, often through a browser with a tool such as Playwright. They give high confidence in critical journeys, but they are slow and fragile, so they should be few.
Load tests
Load tests check behaviour at expected demand, and stress tests find the point at which a system fails. They need a realistic environment, and they run less often, for example nightly or before a major release.
Tests in production
Some confidence comes only from real traffic. Synthetic monitoring runs scripted checks against production, and canary releases compare a small group with the rest. These are extensions of testing, rather than a replacement for it.
Which kind of test?
The test pyramid
The test pyramid recommends many fast unit tests at the base, a moderate number of integration tests in the middle, and a few end-to-end tests at the top. Inverting this creates an ice cream cone of mostly slow, manual or fragile tests, which produces long pipelines and unreliable results.
The following table shows a typical placement in a pipeline. Note how each stage has a longer run time and uses a more realistic environment than the one before it.
| Stage | Tests | Target time | Blocks |
|---|---|---|---|
| Developer machine | Linters and fast unit tests | Seconds | The commit, by habit or hook |
| Pull request | Unit tests, static analysis and fast scans | Under 10 minutes | The merge |
| After merge, test environment | Integration and API tests | Tens of minutes | Promotion |
| Staging | End-to-end and load tests | Tens of minutes to hours | The production release |
| Production | Smoke tests and synthetic monitoring | Continuous | Triggers rollback or an alert |
The following diagram compares an application's current test mix with a test pyramid.

Placing tests in the pipeline
Load testing with Azure Load Testing
Azure Load Testing is a managed service that generates high load without any test infrastructure of your own. It runs tests written for Apache JMeter or Locust, and a URL-based quick test needs no script. It can gather server-side metrics from Azure Monitor, including Application Insights and Container insights, so a slow response can be matched to the resource responsible.
It can run from Azure Pipelines, GitHub Actions or the Azure CLI. Fail criteria define thresholds such as average response time or error percentage, and exceeding one fails the test and therefore the pipeline. Auto stop ends a test automatically when too many errors occur, which limits wasted cost.
# load-test.yaml
version: v0.1
testId: checkout-load
testPlan: checkout.jmx
testType: JMX
engineInstances: 2
failureCriteria:
- avg(response_time_ms) > 500
- percentage(error) > 5
autoStop:
errorPercentage: 80
timeWindow: 60The AzureLoadTest@1 task in Azure Pipelines and the azure/load-testing action read this file and run the test.
A load test that never fails
Speeding up feedback
A team's pipeline takes 95 minutes, and 80 minutes of that is 600 browser-based end-to-end tests. Developers now batch their changes to avoid waiting. Unit test coverage is low. What should you recommend?
The team has an inverted pyramid. It should move most of those checks down to unit and API-level tests, keep a small set of end-to-end tests for critical journeys, and run the full suite outside of the pull request path, for example nightly. Pull requests then get feedback in minutes. Simply buying more agents would shorten the run a little, and it would keep the fragile suite. Removing the tests without replacing them would lose protection.
What two file formats of test script does Azure Load Testing run?
Show answer
Apache JMeter and Locust scripts. A URL-based quick test needs no script.
Exam Tips
Remember for the exam
- Run the fastest tests first, and catch defects as early as possible.
- The pyramid has many unit tests, fewer integration tests and few end-to-end tests.
- Local tests are not enforced, so pipelines must repeat important checks.
- Azure Load Testing supports JMeter and Locust, with fail criteria.
- Keep pull request feedback within minutes.