AI-assisted testing

AI wrote a test that passed but checked nothing

An illustrative situation: the test passes and the pipeline is green. The suite has thirty more tests than it did last week. One month later, a defect in the ordering process reaches production, even though the report says that process is covered by a test. The test merely opened the page, clicked a button and finished. It checked nothing. It passed without verifying the correct order outcome. The steps themselves could still have failed with a technical error.

Why such a test is created

A language model composes a draft from the instructions and available context. If the instructions describe only the steps and do not specify the correct result, the model may create a script that clicks through the process without checking its substance. The same mistake can also occur in a manually written test.

It appears in several forms:

Why this kind of test is particularly risky

A visibly failed test signals that the application, data or test itself needs to be investigated.

A test that checks nothing does the opposite. It looks like a success. It increases the number of tests, may increase the reported coverage and creates the belief that the journey is protected. The team may rely on the green result even though the test has not confirmed the essential behaviour.

A successful run does not itself highlight a missing assertion of the essential outcome. Without a deliberate review, it may remain in the suite for a long time.

How we address it

In AI-assisted testing, human review is therefore part of test creation, not a formal step at the end.

During the review, we focus particularly on the following questions:

Only a draft with a clear expected result, suitable data and an understandable reason for any failure is added to the suite. AI prepares the draft and a person approves it.

The expected result needs an independent basis

Before writing the test, identify the rule, input and result. For an illustrative purchase of two units at 12 euros each, with no discount, shipping or other price adjustments, you expect 24 euros. An amount existing or being positive is insufficient. The test must distinguish the correct 24 euros from an incorrect 12 euros.

Do not calculate the expectation using the same application function whose output you are checking. The same defect could affect both sides of the comparison. Your basis can be an agreed rule, a specific requirements example or an independently prepared expected value.

For an order, also check the record’s identity. An existing order belonging to another customer or an earlier run is not evidence of a correct result in the current test. According to the scenario’s scope, verify the identifier, owner, items, quantity, amount and status. Every test need not check everything, but its name should match what it actually confirms.

A short example of checking the amount

This is an illustrative unit test of a calculation. It does not create an order or launch a browser. It assumes an existing application module named checkout with a function accepting a unit price in cents and a quantity. Adapt the import paths to your project. Python uses pytest, while TypeScript uses the Playwright Test runner, which can also run such tests. The pytest-playwright plugin is not needed here. Both versions check the same inputs and result.

import { test, expect } from '@playwright/test';
import { calculateTotalCents } from './checkout';

test('two units cost 2400 cents', () => {
  const total = calculateTotalCents(1200, 2);
  expect(total).toBe(2400);
});
from checkout import calculate_total_cents

def test_two_units_cost_2400_cents():
    total = calculate_total_cents(1200, 2)
    assert total == 2400

If the function mistakenly returns the price of only one unit, these assertions should fail. Calling the function alone or checking that the result is greater than zero would not detect that defect. The example does not cover discounts, rounding or order persistence. Those rules require further cases.

What to review in the test code itself

The number of assertions does not measure their effectiveness. One precise assertion may protect a rule better than several checks of unimportant headings. During review, also examine execution:

For a UI test, wait for the agreed outcome rather than simply a delay after clicking. If a state develops over time, use a supported waiting assertion with a reasonable limit. Successfully waiting for arbitrary text still does not replace checking the correct amount or order.

How to verify that a test actually detects a defect

Prepare a known incorrect result in an isolated test environment. In the example above, have the calculation return 1,200 cents instead of 2,400. Keep the expected value at 2,400. Verify that the amount comparison failed, rather than the import, data setup or runner launch. Then restore the correct state and verify a successful run.

Deliberately changing the expectation is a narrower check: it demonstrates that the assertion executes and its failure reaches the result. It does not itself prove that the test reads the correct application value. For a critical rule, therefore also assess a controlled change to the application’s output or behaviour.

Mutation testing can automate part of this work. A tool deliberately changes code and observes the tests’ response. Stryker distinguishes detected and surviving mutations as well as execution errors. A surviving mutation warrants investigation. It does not always mean a missing test, because an equivalent mutation can preserve the same behaviour. The resulting score does not guarantee a defect-free application.

How to review an existing suite without rewriting everything

First choose tests of critical rules and recently fixed defects. For each test, record what it protects, the incorrect result it must detect and where it reads the actual output. Also classify its status: executed and effective, weak assertion, not executed or not yet assessed.

Repair or replace a weak test according to its purpose. More variations of the same click-through procedure will not solve the problem. Keep the basis for the expectation and the controlled-failure result in the review so another person can repeat the effectiveness check. Reviewing AI drafts then relies on specific behaviour rather than readable code alone.

What you gain

Next step

Choose several critical tests and, for each one, name a specific defect that must make it fail. If you need an independent assessment of an existing suite, use a no-obligation consultation. We follow a similar approach when repairing a test suite.

Related topics

You might also be interested in

AI will speed up work. The person is responsible for the result.

AI speeds up the design, creation, repair and migration of web, Android, API and Electron tests; a specialist verifies every output before use.