QA Interview Hub · Knowledge base · Quizzes · Українська

Product Engineering › A/B tests and feature flags

A/B tests from the QA point of view

An A/B test randomly splits the audience into control and variant and compares a target metric to find out whether the difference is not random. QA checks the cleanliness of the experiment: a stable group assignment, working functionality and analytics in every variant, and a single exposure event. A deviation from the planned split (sample ratio mismatch) usually means a defect, and duration is set before the start.

Product Engineering · Experiments

Variant B got ahead of control on day two and the team wants to stop the test. What does QA say?

A test of a new payment page is set for 14 days. On day two variant B shows +9% conversion, and someone writes in the chat: "let us roll it out already". QA knows there are two risks at this moment: the win may be random, and the test itself may be broken, in which case something other than intended is being compared. This lesson is about what QA checks in an A/B test and why "the numbers look good" does not mean "the experiment is right".

How it works and why. An A/B test is an experiment in which the audience is randomly split into groups: control (the current experience) and one or more variants (the change). Then the target metric (conversion, retention) is compared and statistics check whether the difference is not random. It answers "does the change actually help", not "do we like it". Randomness is needed so that the groups differ only by the change: if more active users land in B, the audience produces the difference, not the idea.

In practice "random" means deterministic: the group is computed from a hash of the user identifier and the experiment name. Then a person always lands in the same group, and different experiments are distributed independently of each other:

A user’s life in an experiment

1. Group assignmenta hash of the id and experiment name2. Showing the variantthe same in every session3. Exposure eventonce, with the group name4. Metric collectionwithin a term set in advance5. Conclusionstatistics, not an impression
Figure 1. QA checks steps 1-3 most: if they are wrong, the metric at step 4 compares the wrong people.

Example: assignment stability. The simplest scheme and a check that it works:

import { createHash } from 'node:crypto';

// one user + one experiment = always the same group
export function assign(userId: string, experiment: string) {
  const hash = createHash('sha256')
    .update(experiment + ':' + userId)
    .digest();
  return hash.readUInt32BE(0) % 100 < 50 ? 'variant' : 'control';
}

// a check of stability and distribution
const ids = Array.from({ length: 10_000 }, (_, i) => 'user-' + i);
const groups = ids.map((id) => assign(id, 'new-checkout'));
const share = groups.filter((g) => g === 'variant').length / ids.length;
// expect about 0.5; a second call gives the same groups

Two checks are useful here. The same userId gives the same group at every call and after a reload. And on a large sample the distribution is close to 50/50. If it deviates noticeably, it is a sample ratio mismatch: for example, 5,000 each were expected and 5,400 and 4,600 came out. On such a sample the difference is not random, and it is almost always a defect (one variant crashes more often, exposure is counted in only one group, bots fall into one of the groups). The result of such a test deserves no trust until the cause is found.

What else QA should know:

  • Assignment stability. After a reload, a sign-in from another device (if there is an identifier) or a new session, the person sees the same variant. If they see A, then B, their data distorts the result, and the experience looks like a bug;
  • Check all variants. Every variant is a separate version of the product. Functionality, layout, analytics, localisation and accessibility need tests in each. A common mistake is to test only "the new";
  • Forced assignment. For testing you need a way to get into a variant (a query parameter, a cookie, an internal tool) instead of waiting for chance. Such a mechanism must not be open to everyone in production;
  • The exposure event (the user saw the variant) is sent once and with the group name. Otherwise the metrics compare the wrong people;
  • Overlapping experiments. Two tests on one screen can influence each other. They are separated (mutually exclusive groups, layers) or accounted for in the analysis;
  • Quality of variants. A variant that breaks some browsers or slows the page loses because of a defect, not because of the idea. QA protects the purity of the experiment.

Do not peek at the result. The duration and the required sample size are set before the start. If you stop the test as soon as a variant pulls ahead, there is a high chance of a false "win" due to random fluctuations: on small numbers the difference appears and disappears. The principle of sample size is: the smaller the expected difference and the higher the required confidence, the more users and time are needed. A few days on low traffic usually prove nothing. QA's role here is not to compute p-values but not to push for an early conclusion and to remind about the agreed plan.

When to stop a test

Wrong

Stop as soon as B pulls ahead

A difference on day two may be noise. The decision rests on chance and later "does not reproduce".

Right

Stop according to the plan

The term and the sample are set before the start. The conclusion is drawn once, when the data is collected.

Figure 2. Stopping rules are written down before the start, not fitted to the result.

Limits and alternatives. An A/B test needs enough traffic: on a small product it will run for months, and then qualitative methods (interviews, usability tests) or a gradual rollout with metric monitoring are more useful. There are statistical methods that allow interim looks (sequential tests), but the tool itself supports them, and peeking "by hand" is still not allowed. A test does not answer "why": it only says that a difference exists. And a novelty effect may fade within a week, so very short tests mislead.

Common mistakes.

  • Testing only "the new" and not checking the old variant: control has defects too after code changes.
  • Leaving forced assignment open in production: anyone can pick a variant and distort the data.
  • Counting exposure on every render rather than once per user.
  • Ignoring a deviation from the planned group ratio (sample ratio mismatch).
  • Allowing a stop "when it wins".
  • Running two tests on one screen without accounting for the influence.

Check yourself

A user opens the site on a phone and sees variant A, then on a laptop after signing in sees B. What is it and why is it a problem?

Answer

The assignment is unstable: the group is not computed from a stable identifier (for an anonymous user across devices it is expected, for a signed-in one it is not). Their data lands in different groups and distorts the result, and the experience itself looks like a bug. Check that after sign-in the assignment is tied to the user and does not change.

A 50/50 split with 5,000 users per group was planned, in fact 5,400 and 4,600. What do you do with the test result?

Answer

Do not trust it until the cause is found: it is a sample ratio mismatch, and a difference of that size on this sample is not random. Look for defects: one variant crashes more often or loads slower, exposure is recorded in only one group, bots land in one group.

In an interview. Junior: An A/B test splits the audience into control and variant and compares a metric. QA checks that a user stably sees their group, that every variant works, that the exposure event is sent once and that forced assignment for tests is not open in production. Middle/Senior: I look at the purity of the experiment: sample ratio mismatch, overlap with other tests, the quality of variants and the analytics. I do not push for an early conclusion: the duration and sample are set before the start, because a win on day two may be noise. I understand that a test says "is there a difference" but not "why".

More articles in this chapter