QA Interview Hub · Knowledge base · Quizzes · Українська
AI-driven Automation
Validating an agent’s output
How to read tests written by an agent: red flags
A green test only says it did not fail, so an agent's tests are read critically: can the assertion fail at all. Red flags: an assertion like "defined" instead of the expected value, expectations copied from the current implementation, invented selectors and APIs, over-mocking, weak patches, forgotten test.only and test.skip, and duplicates. Run the test yourself.
An agent brought a PR: "12 tests added, all green". A green test only says that it did not fail. Whether it is able to fail at all must be checked.
Red flags during review:
- an assertion that cannot fail: a "not empty" or "defined" check instead of the expected value;
- the test records the implementation, not the behaviour: the expectation is taken from what the application does now;
- invented selectors and APIs: a method absent from the documentation; a locator absent from the page;
- over-mocking: the server response is supplied by the test itself, so the real integration is not verified;
- weak patches: a weakened expectation, an increased timeout;
- forgotten
test.only and test.skip: CI is green but part of the tests did not run;
- duplicates: many tests check the same thing by different paths.
Example. A cart test checks that the total text is "defined". It will pass even on "NaN". A correct assertion compares the total with the one expected by the pricing rules.
Common mistakes: reading only test names; trusting the count; not running the test yourself.
Short interview answer: "I read an agent’s test like anyone else’s: can it fail, what exactly does it check, has the volume grown through duplicates".
Can the test fail: repeat, break, look at the trace
An agent's test is checked in three dimensions: stability, the ability to fail, and evidence of the run. Stability is checked by repeated runs (--repeat-each), not by retries, which hide flakiness; the ability to fail by deliberately breaking the behaviour or by mutation testing; evidence by the trace, video and screenshots. A single green run proves nothing.
An agent wrote a test, and it passed the first time. One green run is not enough: two things must be proven — that the test is stable and that it catches a defect.
1. Stability. A flaky test passes sometimes. A cheap way is to run it many times: npx playwright test login --repeat-each=20. Retries (--retries) hurt here: Playwright only marks a test that failed and passed on retry as flaky, and the build stays green (unless --fail-on-flaky-tests is set). In CI, enable forbidOnly so a forgotten test.only breaks the build.
2. Ability to fail. Deliberately break the behaviour: change the total, remove a step, return an error. If the test stays green, it checks nothing. The automated version is mutation testing: a tool makes small changes to the code and counts how many of them the tests noticed.
3. Run evidence. The trace, video and screenshots show what the agent really did in the browser. That is more reliable than the phrase "checked the UI".
Example. An order creation test repeated 20 times: 18 green, 2 red because of a race with loading the list. That is flakiness the agent would not see in a single run.
Common mistakes: treating one green run as proof; "healing" flakiness with retries; not breaking the application for a check.
Short interview answer: "I repeat runs for stability, break the behaviour to see red, and look at the trace as evidence".
An agent’s report: evidence instead of words, golden set
An agent's report is a claim to verify, not to take on trust. Demand the diff, the output of a reproducible command, a trace or video, and a list of what was not verified. Expectations come from a specification, not current behaviour. A change of model or instructions is measured on a golden set: a fixed task set with known defects, counting found defects and false green runs.
An agent writes: "Added 12 tests, all pass". The PR has nine tests, two of them under skip. An agent’s report is a claim, and it is checked like everything else.
What to demand instead of words:
- the diff of changes (how many files and which, whether there are foreign ones);
- the output of a check command that you can run yourself;
- a trace or video of the scenarios;
- a list of what was not verified and which assumptions were made.
An oracle from requirements. An agent reads the code and the interface, so it easily "confirms" the existing behaviour, bugs included. Expectations should come from a specification, acceptance criteria or an agreed rule, not only from observation.
Golden set. When you change the model or the agent’s instructions, the question "did it get worse?" needs a measurement. Build a fixed set of tasks and applications with known defects. After each change, see how many defects the tests found and how many green runs were false. The number of generated tests proves nothing.
Example. After instructions were replaced, the agent found 7 of 10 defects on the golden set against 9 before, although there were more tests. The change is rolled back.
Common mistakes: trusting the summary; checking five random tests and concluding about all; asking the agent whether it got better.
Short interview answer: "An agent’s words are a hypothesis: I ask for a diff, a reproducible run and a trace, and I measure the quality of changes on a golden set".