AI-Generated Tests: 7 Checks to Verify They Are Effective, Not Just Green

    AI can generate clean, passing test code in seconds, but a green run does not prove that a test protects business behavior. This article outlines seven practical checks for AI-generated tests: requirements and scenario coverage, business-outcome assertions, defect injection, independence and repeatability, locator robustness, negative and boundary paths, and maintainability. It then explains how to institutionalize those checks through scenario-first generation, defect-injection exercises in CI, assertion-focused review, and source tagging. Readers will learn how to move AI-assisted testing from superficial compliance to a reliable safeguard for the system.

    The Core Problem: A Green Test Is Not an Effective Test

    AI’s ability to generate test code has improved dramatically. Given a page or endpoint description, a model can produce a structured end-to-end test script in seconds: the locators look reasonable, asynchronous waits are complete, assertions use modern mechanisms with automatic retries, and the first run is likely to be green. In a quick review, such code is easy to approve.

    The problem is hidden precisely there. Imagine a defect in the application: when saving an invoice actually fails, the page still incorrectly displays a “created successfully” message. The test described above still passes because it asserts that message. The test does not lie, but it offers no protection either.

    That is the central tension: the cost of generating automation code is approaching zero, while making tests reliable, meaningful, and maintainable still requires human judgment. Models are good at producing tests that look correct. Whether those tests truly protect business logic is a completely separate question. After AI generates tests, apply the following seven checks one by one.

    Seven Checks: Moving from Formal Review to Substantive Review

    Check 1: Start with Requirements; Gaps Usually Live in Scenarios, Not in Code

    Before reviewing the code line by line, answer a more fundamental question: what is this test supposed to prove?

    Take “create invoice” as an example. The questions truly worth verifying may include:

    • Must invoice numbers be unique? Are duplicate saves allowed?
    • What should happen when required fields are missing?
    • After a successful save, does the invoice appear in the list?
    • Are there business rules that decide whether saving is allowed, such as an amount cap or vendor status?

    The model only knows what the prompt tells it. If the requirements do not mention duplicate invoice numbers, the generated tests will not cover duplicates. Such gaps cannot be found by reading the code, because the code itself may be perfectly correct; what is missing is the scenario.

    So the first check is always: map out the requirements, list the scenarios that should be covered, and then compare how many of them the generated tests cover. Skip this step, and it is easy to end up with a smoothly running test case that protects only a very narrow path.

    Check 2: Does the Assertion Verify a Business Outcome or a Byproduct of an Interaction?

    Return to the “created successfully” message. If the requirement itself defines the behavior as “display a success message,” then asserting that message is fine. But if the requirement is “create an invoice record,” that message is not sufficient evidence. It is rendered UI copy, not a data-layer fact.

    A more reliable approach is to assert the actual system state. For example, if saving takes the user to a detail page, verify the real data on that page instead:

    1. await expect(page.getByRole('heading', { name: 'INV-001' })).toBeVisible();
    2. await expect(page.getByText('Supplier A', { exact: true })).toBeVisible();

    For critical business flows, you can go further and add checks at the data layer, such as querying the relevant API to confirm that the record exists. This binds assertions to results that cannot easily be faked, rather than to volatile UI copy.

    Check 3: Use Defect Injection to Test the Test’s Detection Ability

    The most direct way to judge whether a test is effective is to ask: if the defect it is supposed to protect against actually occurred, would it fail?

    In practice, inject a scenario-related defect into the code. For example, make the save endpoint return an error, comment out validation logic, or let duplicate invoice numbers bypass the uniqueness check. Then run the test. If the test is still completely green, it cannot detect that kind of defect and is effectively useless.

    This is a classic principle in testing: a test that has never failed has questionable effectiveness, while a test that reliably turns red when the corresponding defect is injected is a real safety net. AI-generated tests especially need this validation because the model optimizes for making tests pass, not for making tests catch problems.

    Check 4: Review Test Independence and Repeatability

    • Are there implicit dependencies between tests, such as one test reusing data created by a previous test?
    • Does the test still pass reliably when run in a different order or in a clean environment?
    • Does it depend on fixed times, random data, or the live state of external services?

    Tests with tangled dependencies are very expensive to diagnose when they fail, and the cause is often unrelated to the logic under test. Ideally, AI-generated tests should bring their own data setup and cleanup, and run in any order and any environment.

    Check 5: Inspect Locator and Selector Robustness

    Model-generated locator strategies often work today and become fragile tomorrow. Check each one:

    • Does it prioritize semantic locators, such as roles, labels, and accessible names, instead of relying on DOM hierarchy or dynamically generated style class names?
    • Does it depend on render order or patterns such as nth-child that break easily during UI refactors?
    • Will assertion copy conflict with internationalization or multilingual configuration?

    Fragile selectors turn a test suite into a maintenance burden. Every small frontend change causes widespread failures, and the team quickly loses trust in the failures.

    Check 6: Check Coverage of Negative Paths and Boundary Conditions

    AI shows a clear bias toward the happy path when generating tests: fill out the form, click the button, see success. But most real system defects hide in branches:

    • What does the user see on a network timeout or when the API returns an error code?
    • How does validation behave with excessively long input, special characters, or invalid formats?
    • When concurrent operations target the same resource, do the results match expectations?

    Compare these negative scenarios against the requirements checklist item by item. This is a key way to counteract the model’s tendency to focus on success and overlook failure.

    Check 7: Evaluate Maintainability and Team Comprehension Cost

    Finally, ask a few engineering-level questions:

    • Do test names accurately describe the business behavior they verify, or are they placeholders such as test1 and test2?
    • Should shared steps be extracted into reusable helper functions, or is there heavy copy-paste?
    • Can a team member understand what the test protects within five minutes?

    Tests are written for your future self and for your colleagues. A hard-to-read test may be effective today, but it will gradually lose value as it is maintained.

    Turn the Seven Checks into a Process

    One-off reviews are remediation; a fixed process is assurance. Consider institutionalizing these practices in the engineering workflow:

    1. Use a scenario checklist first. Have humans map out the business scenarios before AI generates targeted tests. This is much more efficient than generating first and then hunting for gaps.
    2. Keep defect-injection drills in CI. Periodically run mutation validation on critical tests and quantify the suite’s real detection rate.
    3. Shift review focus from code style to assertion validity. Style issues can be checked by tools and models; human attention should go to “what does this test actually prove?”
    4. Tag AI-generated tests with their source. This makes it easier to track their defect-detection performance over time and continuously improve prompts and review strategies.

    Conclusion

    AI has dramatically compressed the time cost of writing test code, but this also shifts where test value lies: from “can we write it?” to “once written, does it actually protect the system?” A system that passes every test yet still ships a major defect often does not have a testing-tool problem. Instead, no one ever asked those green check marks, “What did you actually prove?”

    Treat the seven checks above as a standard post-generation review workflow for AI-generated tests. Only then can automated testing move from formal compliance to substantive reliability. That is precisely the irreplaceable value of human engineers in the era of AI-assisted testing.