Skip to content
TestLine Menu
TestLine
QA process

How to set up a test environment (staging) so testing goes fast

What testers need from staging, a checklist to tick off before testing starts, and the mistakes that make testing take twice as long.

author
Artur Machowski, Senior QA Engineer
published
reading
6 min

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 noindex header or a block in robots.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

problemeffectsolution
manual deployments once a weekthe tester waits for changes, tests pile up before the releasedeployment after every merge
no test datahalf a day preparing data before regressiona data script
an unstable environmentreports mix application bugs with environment problemsmonitoring and an environment owner
no payment sandboxpayments go untested or get tested in productiona test account with the provider
no email captureemails go untested or get sent to real peopleMailpit or Mailtrap
one staging for several teamsone team’s changes break another team’s testsbranch 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.

Frequently asked questions

What is a test environment (staging)?

It's a copy of the application where the team tests changes before releasing them to production. It should have the same configuration and service versions as production, but its own test data, payment sandboxes and email capture.

Does staging have to be the same as production?

The configuration, service versions, environment variables and deployment method, yes. Server size and data volume can be smaller, unless you run performance tests on staging. Every difference is a place where a bug can slip through to production.

Where should staging data come from?

Ideally from synthetic data loaded by a script: accounts for every role, products, orders in different states. A copy of production contains personal data covered by GDPR, so it needs a legal basis and full anonymisation.

How do you stop staging from sending emails to real customers?

Route all email from staging to a tool that captures it, e.g. Mailpit or Mailtrap. Testers then see every email in the browser, and none reaches a real inbox.

Should staging be publicly accessible?

No. Ideally behind a VPN, a login or an IP allowlist, and with a noindex header so search engines don't index it. A public staging with a copy of the data is a common source of leaks.

Got a release in a few weeks?

Describe your project in the form. I'll reply with questions about scope or an initial test plan.