EveryRole

Testing in production, safely

Testing in production is safe under six rules: test accounts, never-click words, named test data, clean-up, no retry after a real send, a stop before money.

Testing in production means running real journeys on the app your customers use. It is the only place where your live settings, your real data and the services around your app are all present at once, so it is the only place some bugs exist. It is safe if every test follows six rules: test accounts only, a list of words no test ever clicks, test data that is named as such, clean-up of what the run made, no second try after a real send, and a hard stop before money and real people.

This post isn’t about feature flags or gradual rollouts. Those are good tools for releasing. It is about the other half: checking, after the release, that a person can still sign up and do the thing.

Six rules for testing on the live app: test accounts only, words no test ever clicks, everything a test makes is named, clean up what the run made and only that, no second try after a real send, stop before money and real people
Each rule exists because of a specific way a test can hurt a live app.

Why test on the live app at all

Because a preview and a staging server answer a different question. They tell you whether the new code works. They can’t tell you that production’s payment key is the right one, that the migration finished on the real table, or that the sign-in service accepts your real domain. We listed those gaps in the post on E2E tests on preview deployments.

So the journeys that matter get walked on production too, after every deploy and on a schedule. The question is only how to do it without leaving marks.

How to test in production safely: the six rules

1. Test accounts only

Every test signs in as an account made for testing: one per kind of user, with the least access its journeys need. Never a customer’s account, and never your own admin login, which can reach things no test should be near. Where their logins should live is in test credentials in CI.

Mark these accounts so the rest of the company can recognise them: left out of revenue reports and analytics, skipped by the sales team’s follow-up emails.

2. Words no test ever clicks

A test follows its script. If the script is wrong, or the page changed, or an AI model is choosing the next click, the script is not a safety rule. The safety rule is a list of words that are refused before any click, whatever the test intended: Pay, Buy, Delete, Remove, Send, Cancel subscription, Close account.

The list is per app, because the dangerous button is named differently everywhere. Read your own app and add its words: “Archive”, “Publish”, “Invite all”.

3. Everything a test makes is named

When a test creates something, its name carries a marker: the run’s id, or at least the word “test” and a date. Sample item 7f3a instead of Sample item.

That marker earns its place. Clean-up can find exactly what this run made. A leftover is recognised at a glance by anyone who meets it. And two runs at the same time don’t trip over each other’s data.

4. Clean up what the run made, and only that

After the run, delete what it created, through the app’s own delete control, as the account that made it. Then check it is gone from its page and from its list.

“Only that” matters as much as the deleting. A clean-up that removes “everything named Sample” will one day meet a customer who named something Sample. The marker from rule 3 is what makes a narrow clean-up possible.

When the app has no way to delete the thing, the honest result is to say so, loudly, and keep that test for staging. We go through the cases in test data cleanup.

5. No second try after a real send

The habit with a failed test is to run it again. On production that habit is dangerous. If the test already pressed the button that created an order, sent an invitation or started slow work on the server, running it again does all of that a second time, and then the retry “passes” and hides both.

So split failures in two. A test that failed before it sent anything can be tried again. A test that failed after a real send is reported as it is, with what it sent, and left for a person. It is also the honest way to treat flaky tests: a pass on the second try is a different result from a pass.

6. Stop before money and real people

The checkout journey goes up to the payment step, checks the plan and the total, and stops. We described the walk in how to test checkout without paying. The payment itself is tested in the provider’s test mode, on a test environment.

The same line applies to messages. A test may trigger an email to its own test inbox. It may never trigger one to a customer, a mailing list, or “everyone in the workspace”.

What we’d keep off production

  • Load tests. Your customers are the load.
  • Bulk actions. Import, export-all, delete-all. Test them where the data is made up.
  • Account-level destruction. Closing an account, cancelling a subscription, transferring ownership.
  • Anything you can’t undo and can’t mark. If rule 3 or rule 4 can’t be followed, the test doesn’t belong here.

And pace it. A test run is extra traffic from one address. Spread the requests out, and tell whoever watches your security alerts where they come from.

Testing in production needs more than production smoke tests

The smallest version of testing in production is a smoke test: is the site up, does the home page answer. Keep it, and don’t mistake it for coverage. A site can answer on every page while sign-up is broken. The value of testing on production is in the journeys: sign up, log in, the main thing your app does, the walk to payment, each ending on a result you can see.

Under the six rules, those are safe to run every day.

How EveryRole follows the rules

EveryRole tests a live app from the outside, and these rules are built into it.

It signs in with the test logins you give it, one per kind of user. Before every click, while exploring and in every test, it refuses a button or link that holds one of the app’s never-click words.

EveryRole's never-click setting: "Before every click, while exploring and in every test, EveryRole refuses a button or link with one of these words", with Delete, Remove, Sign out, Unsubscribe, Cancel subscription, Pay, Buy and others, and a field to add another word
The never-click list in an app’s settings. You add the words your own app uses.

What a run makes is marked with the run’s id. After the run it cleans up what that run made, and only that, through the app’s own controls, then checks it is gone. When it can’t, because the app offers no delete, it says so in a plain sentence.

A test that really sent something to your app is never run a second time because it failed. On a page with plans, the case ends at the payment step. It never pays.

On production it is stricter still. A test that creates, edits, deletes or uploads runs on your preview deploys first, and reaches production only after it passed there and you said yes again. A plan’s button that holds a word like Buy waits for your yes, and even then is pressed only on a preview, never on production.

While it explores an app, every request that would save is blocked in the browser. That blocker has a limit we state in the docs: it works inside the page, so it doesn’t see what a service worker or a websocket sends, or an app that changes data on a plain page load. The never-click list is there for that reason, and so is rule 1.

Keep reading

Deploys and CI

Run E2E tests on every preview deployment

To run E2E tests on preview deployments, wait for the deploy, take its address and run your journeys there. Five traps, and what a preview can’t prove.

6 min read

Deploys and CI

Run tests after every deploy, not every night

Post-deployment testing: the deploy starts the tests on the live address, and the result names that deploy. The set-up, and what a nightly run is still for.

5 min read

Deploys and CI

Test credentials in CI: where test logins belong

Test credentials in CI belong in the pipeline’s masked variables, one pair per kind of user, typed by the job itself. Seven rules, and where they leak.

6 min read