Short answer
A good test environment (staging) has the same configuration and service versions as production, test data and accounts loaded by a script, sandboxes for payments and external services, email and SMS capture, automatic deployment after every merge and access for the team only. Then the tester tests changes straight away instead of waiting for a deployment or preparing data. Every difference between staging and production is a place where a bug can slip through.
Staging checklist
Parity with production
- the same versions of the database, cache, queues and services;
- the same environment variables, apart from addresses and keys;
- the same deployment method, e.g. the same pipeline with a different target;
- database migrations run the same way as in production.
Test data and accounts
- accounts for every role, with passwords in the team’s password manager;
- data in different states: a new customer, a customer with history, an order that’s paid, cancelled, returned;
- a script that restores the data after the environment is refreshed;
- synthetic data instead of a copy of production. I describe how to prepare it in the test data guide.
External services
- a payment provider sandbox with test cards and accounts;
- email capture, e.g. Mailpit or Mailtrap, and SMS capture; how to use them in tests is covered in testing emails and SMS;
- sandboxes or stubs for partner systems, e.g. couriers and accounting;
- separate API keys, so tests don’t use up production limits.
Deployments
- automatic deployment to staging after every merge to the main branch;
- a visible app version, e.g. the commit hash in the footer or at
/version; - the option to deploy a branch to a separate environment if the team tests features in parallel;
- a note in the team channel on what was deployed and when.
Access and security
- access via VPN, a login or an IP allowlist;
- a
noindexheader or a block inrobots.txt, so staging doesn’t end up in search engines; - no personal data from production.
Observability
- application logs available to testers;
- an error tracking tool, e.g. Sentry, on staging too;
- basic metrics: is the environment up at all.
What slows testing down
| problem | effect | solution |
|---|---|---|
| manual deployments once a week | the tester waits for changes, tests pile up before the release | deployment after every merge |
| no test data | half a day preparing data before regression | a data script |
| an unstable environment | reports mix application bugs with environment problems | monitoring and an environment owner |
| no payment sandbox | payments go untested or get tested in production | a test account with the provider |
| no email capture | emails go untested or get sent to real people | Mailpit or Mailtrap |
| one staging for several teams | one team’s changes break another team’s tests | branch environments or booking |
Who owns staging
A test environment needs an owner, usually the DevOps person or the tech lead. The tester reports environment problems the same way as application bugs, but shouldn’t fix them alone. When nobody owns staging, over time it stops resembling production and testing loses its value.
How I can help
Before I start testing as part of QA support, I go through this checklist with the team and say what’s missing. As part of test automation I prepare test data scripts and set tests to run on staging after every deployment. What to prepare for the first week of working together is covered in the first week with an external QA. Describe your environment in the contact form.