Ler original em português

← All content

dooopSoftware · Quality · 11 min

How to Identify Fragile Tests Generated by AI

AI-generated tests may appear solid yet still fail to protect business rules. Learn how to review assertions, negative cases, and boundaries.

Published on September 6, 2026

CORE THESIS

A green test can hide an unprotected rule. Review starts with the error the test should detect.

Replace appearance with behavior mutation. A strong test fails when the relevant rule is violated.

A test suite generated by artificial intelligence can seem mature yet provide little protection. The risk begins when a green test acts as a security certificate but would not fail in the face of incorrect behavior. When it only confirms the happy path, duplicates the implementation, or verifies internal calls without observable effect, it increases the sense of security without increasing confidence in the rule the software should enforce.

The warning sign is a neat test that only confirms the implementation

A recurring problem in reviewing AI-generated tests is confusing polish with evidence. They come well named, grouped, with familiar structure and clear messages. They pass the pipeline. At first glance, they seem ready to enter the suite.

But appearance is not evidence.

A fragile test may call the right function, assemble plausible data, and check that something happened. Still, it does not demonstrate that the business rule was protected. In many cases, the verification is so close to the implementation that the test fails when the code is reorganized but passes when the rule is violated.

For engineering, quality, and product leadership, this is the worst kind of test: expensive to maintain and weak at detecting errors.

The AI origin does not automatically make the test bad. A test written by a person can also be fragile. In internal reviews, treat volume and good polish as possible sources of complacency, not as evidence of quality. The review must compensate for this risk: less enchantment with form, more investigation of the error the test could detect.

DORA recommends treating tests as part of development, combining automation with manual activities such as exploratory and usability testing, and maintaining and reviewing test suites over time DORA. This recommendation helps frame the problem: automated tests are not artifacts that enter the codebase and become immune to criticism. They also need to be reviewed.

If the organization is discussing a broader practice of software quality with AI, the question of fragile tests is a specific piece of that system. It does not solve acceptance, observability, code review, or production decisions. But it prevents a growing suite from becoming just a green report.

The central question is: what error would make this test fail?

Reviewing AI-generated tests should start with a simple question: what concrete error would this test detect?

It is not enough to answer "it tests the discount function" or "it tests the checkout component." That names a code area, not a protected behavior. A better answer would be: "this test fails if an expired coupon is accepted," "this test fails if an order below the minimum value receives a discount," or "this test fails if the system allows prohibited coupon combinations."

The difference seems small. It is not.

When you name the detectable error, you shift the review from execution to decision. The test ceases to be proof that the code runs and becomes a barrier against undesired behavior.

In practice, look for errors such as:

  • reversing a relevant condition;
  • accepting a status that should be rejected;
  • ignoring a value, deadline, or quantity limit;
  • returning a message incompatible with the rule;
  • applying a transformation when the input should be rejected;
  • allowing a combination the product prohibits.

If none of these errors would make the test fail, the test may be measuring activity, not quality.

This question also helps separate redundant tests from complementary tests. Two checks may have different names and cover the same behavior. On the other hand, a single flow may need different cases when each protects a distinct product decision.

This reasoning relates to the topic of acceptance criteria for AI features, but here the focus is narrower: what an automated test can detect when the code behaves incorrectly.

Behavior mutation can be light without becoming a heavy process

A practical way to review fragile tests is to imagine a behavior mutation. That is, an incorrect change in the expected rule.

This does not need to start as a formal mutation testing tool. It can be a review practice. The reviewer chooses a relevant test, imagines an incorrect code change, and asks if the assertion would catch that change.

The procedure can be simple:

  • choose a test that protects a relevant rule;
  • write in natural language the behavior that should be prohibited;
  • imagine an incorrect code change that would allow that behavior;
  • check if the current assertion would fail;
  • decide whether to keep, fix, complement, or remove the test from the critical suite.

The word "critical" matters. Not every test needs the same level of scrutiny. Tests protecting business rules, sensitive integrations, permissions, calculations, states, and decision flows deserve more attention than low-risk tests about formatting or simple presentation.

This practice also avoids a common trap: requiring every test to know all scenarios. A good test does not need to prove everything. It needs to declare the behavior it protects and fail when that behavior is violated.

Anthropic, when addressing agent evaluations, distinguishes the execution trajectory from the effective result in the environment. A message stating the task is finished is not enough to prove the result; evaluations use inputs, success criteria, and checkers Anthropic. The comparison has limits because testing code and evaluating agents are not the same. Still, the distinction is useful: apparent execution does not equal correct result.

In automated tests, the equivalent is clear. A green pipeline does not prove that incorrect behavior would be detected. It proves that for those inputs and assertions, nothing failed.

Fictional example: coupon applied outside allowed rule

Consider a fictional e-commerce example. The team asks an AI to generate tests for the coupon application function. The product rule states that a coupon can only be applied if it is active, within the deadline, above the minimum value, and not combined with another coupon.

The AI generates a well-named test: "should apply valid coupon to cart." The test creates a cart, adds a coupon, and verifies that the final total changed.

This protects something, but little. It may pass even if the system accepts expired coupons in another scenario. It may pass if cumulative coupons are improperly allowed. It may pass if the minimum value is ignored, as long as the case assembled is comfortably above the limit.

Behavior mutation review would ask:

  • if the code accepted an expired coupon, which test would fail?
  • if the code applied a discount below the minimum value, which test would fail?
  • if the code allowed two coupons that cannot be combined, which test would fail?
  • if the system returned success but did not record the reason for refusal when necessary, which test would fail?

The original test, which only checks if the total changed, does not answer these questions. It confirms the allowed path but does not challenge the rule boundaries.

A stronger suite would have tests with explicit intent. One case would affirm that an active and eligible coupon reduces the total. Another would affirm that an expired coupon is rejected and preserves the total. Another would force the value exactly at the rule-defined limit. Another would place the cart immediately outside the limit. Another would verify the prohibited combination.

None of these tests guarantees the product will be error-free. The expected effect is more modest and honest: increasing the chance that incorrect changes in relevant rules are detected early. This effect needs to be observed in the team's practice, not presumed as an automatic result.

Checklist: does this test detect the wrong behavior?

Use this checklist as a commented review of AI-generated tests. The criteria below are a practical proposal to examine test strength.

Protected behavior

Does the test declare which business rule or observable behavior it protects?

If the answer is only the name of a function, class, endpoint, or component, the test needs to be rewritten around the behavior. A good name helps, but the assertion also needs to point to a verifiable consequence.

Detectable error

Is it possible to name a specific error that would make this test fail?

If no one can say which bug would be caught, there is a strong sign of a false positive test: it passes, occupies space in the suite, but contributes little to confidence.

Input that forces decision

Do the data used in the test force the code to choose between accepting, rejecting, calculating, blocking, or transforming something?

Too generic inputs produce comfortable tests. They show that the basic flow runs but do not pressure the rule. Prefer data that expose a decision condition.

Assertion on observable effect

Does the verification confirm a result perceived by the user, a consuming system, or a business rule?

Assertions on internal calls, mocks, and implementation details may have value in specific contexts. The risk appears when they replace effect verification. If the correct behavior remains the same, a refactor should not break the test without reason.

Negative case

Is there at least one test showing what should not happen?

In review, be suspicious of suites that only confirm valid paths. The rule often lies in refusal: what to block, when to reject, when to preserve state, and when to explain failure.

Relevant boundary

Does the test cover any boundary that would change the system's decision?

Comfortable values rarely reveal fragility. A relevant boundary deserves at least one case at the decision point and another outside it, when that makes sense for the rule.

Resistance to alternative implementation

Would the test remain valid if the implementation changed but the correct behavior was preserved?

If the answer is no, the test may be too coupled to the current solution. This type of coupling makes refactors more expensive without necessarily better protecting the product.

When to keep, fix, or discard an AI-generated test

Review does not need to become a hunt for AI-generated tests. It needs to produce a decision.

Keep the test when it declares a relevant behavior, uses input that forces a decision, and fails in the face of a plausible incorrect mutation. It does not need to be perfect. It needs to protect something the team recognizes as relevant.

Fix the test when the intention is good but the assertion is weak. This happens when the test sets up the right scenario but only verifies that a function was called, an object exists, or a flow ended. In these cases, the best decision is usually to replace the verification with an observable effect.

Complement the test when it covers only the happy path of a rule that also depends on refusals, boundaries, or exceptions. The affirmative test can remain useful as long as it is not sold as sufficient behavior coverage.

Discard the test when it replicates the implementation, protects detail without product value, or increases noise in the suite without capturing a relevant decision. Removing a weak test can be better than preserving it out of attachment to coverage count.

Code coverage and behavior coverage are not synonyms. The first may indicate lines exercised. The second requires asking if relevant decisions were challenged.

This distinction also applies when the team reviews code produced with AI assistance. In how to review AI-generated code, the central point is not to confuse plausibility with correctness. In tests, the same discipline appears differently: do not confuse an organized suite with real protection.

What to automate and what still needs human review

AI can suggest variations, names, test structures, and initial cases. This can be useful as long as the team does not outsource the choice of behavior that deserves protection.

This choice depends on business rules, risk, product history, user expectations, and failure cost. AI can suggest possibilities, but the team must decide which system decisions cannot change without alarm.

There are also tests that should not be treated only as unit automation. DORA includes manual activities such as exploratory and usability testing in the quality approach throughout development DORA. Google SRE discusses gradual releases, evaluating changes on a portion of traffic before broadening exposure Google SRE. These practices do not replace good tests but remind us that quality does not fit in a single layer.

For features with greater uncertainty, the question of fragile tests should connect to other decisions: acceptance criteria, technical review, exploratory testing, observability, gradual rollout, and rollback plan. For simple features, the checklist may suffice as a review filter.

The concrete decision is to examine each relevant test looking for a simple mutation in the expected behavior. If an incorrect code change does not make the test fail, the test should be rewritten, complemented, or removed from the critical suite.

If you want to discuss this decision in your company context, talk to dooop.

Further reading

Sources

To continue this reading

NEXT DECISION

Discuss application in your company

Conversation about your software company context

Content by dooop. Registration allows relating this topic to the reader's journey and tracking interest in the subject.

Conversation about your software company context

We will use your details to deliver this content and contact you about related topics.