AI Test Case Generation Without the Flaky Output

AI test case generation without flaky output, highlighting why AI-generated tests go flaky, generating from a verified spec, deterministic execution, and where AI generation helps.

TL;DR

  • AI test case generation uses a model to produce test cases from an application, a requirement, or a user story, instead of a person writing each one by hand.
  • The common failure is nondeterminism. A model that writes a slightly different test each run, or guesses at brittle locators, builds flakiness into the suite from the start.
  • The fix is to separate generation from execution. Use AI to understand the application and draft a verified specification, then generate a deterministic suite from that spec.
  • This is how Atlas works. It observes how an application behaves, produces a verified spec, and generates tests that run the same way every time on Sahi Pro’s proprietary engine.
  • Honest caveat: AI generation speeds up the first draft and the boring coverage. A person still decides what correct behavior is and signs off on the suite.

Every testing vendor now generates test cases with AI, and the demos look effortless. Point a model at an app, watch it write a hundred tests, and ship. The problem shows up two weeks later, when a third of those tests fail on a UI change that broke nothing, and the team discovers the model wrote fragile locators and inconsistent steps that now cost more to fix than they saved to generate.

AI test case generation is genuinely useful. The difference between a tool that helps and a tool that hands you a maintenance problem is where the AI sits in the pipeline. Used to understand the application and draft a stable specification, it earns its keep. Used to improvise the running test, it manufactures flakiness.

What is AI test case generation?

AI test case generation is the use of a model to create test cases automatically, drawing on the application’s behavior, its requirements, or written user stories, so a team does not author every case by hand. A good implementation produces the test steps, the data, and the checks. The quality question is whether the generated tests are stable enough to run repeatedly without constant repair.

Why do AI-generated tests go flaky?

AI-generated tests go flaky when the model improvises at the wrong layer. A model asked to write and run a test in one motion often pins each step to a brittle locator and produces slightly different output each time, so the suite varies run to run and breaks on the first UI change. A test that does not give the same result on the same input cannot tell you whether a build is safe.

The recurring failure modes:

  • Nondeterministic output. The model generates a different test for the same screen on a second run, so the suite is never stable enough to trust.
  • Brittle locators. The model writes selectors as DOM positions or generated IDs, which break on the next release.
  • Unverified assumptions. The model guesses what correct behavior is instead of being told, so the test encodes a mistake as an assertion.
  • No ground truth. Without a verified picture of how the app actually behaves, the generated suite drifts from reality every time the app changes.

How do you generate tests that stay deterministic?

You keep AI generation stable by splitting the work into two layers. Let the AI do the part it is good at, observing the application and drafting a specification of how it behaves, and keep the running test deterministic underneath. The agentic work belongs in design and adaptation. The execution has to give the same result on the same input every single run.

This is the principle behind Atlas, Sahi Pro’s AI test design studio. Atlas uses AI to observe how an application behaves and produce a verified specification of that behavior, then generates a deterministic test suite from that spec. The model does the understanding and the drafting. The suite that runs behaves the same way every time, on Sahi Pro’s proprietary execution engine, which has 20 years of production use behind it.

What a verified spec changes

A verified specification is the ground truth the generated suite is built from, and it is what keeps AI generation from drifting. Because the spec captures how the application actually behaves, the tests generated from it check real behavior instead of a model’s guess, and when the app changes, the spec gets updated and the suite regenerates, with no hundred hand-patched scripts to chase.

The elements the suite references are identified by relationship and context, by the label beside a field or the text on a button, so a generated test keeps finding the right element after a layout change. That removes the brittle-locator failure mode at the source. The result is AI that drafts and adapts tests on top of a runtime a team can trust. The execution stays the same every run, so generation stops being a source of new maintenance.

Where AI generation helps, and where it does not

AI test case generation earns its keep on the first draft and the broad, repetitive coverage, the cases a person would write slowly and resent. It is weaker, and should be, on deciding what correct behavior is. A model can propose that the checkout total should update when a coupon is applied, and a person still has to confirm that is the intended rule before it becomes an assertion the release depends on. The honest adoption path is to let AI generate and draft, and keep a human defining intent and owning the sign-off.

Generate from a verified spec, keep the gate

AI test case generation is a real time-saver when the AI understands the application and drafts from it, and a maintenance trap when it improvises the running test. Separate the two layers, generate from a verified specification, keep execution deterministic, and keep a person deciding what correct means. See how Atlas generates tests from a verified spec on Sahi Pro’s engine in a working session.

Sources

  • Atlas product mechanism: AI observes application behavior, produces a verified specification, generates a deterministic suite on Sahi Pro’s proprietary engine. Client facts.
  • What Is Agentic QA? The Complete Guide for 2026, Katalon, 2026, for the market context on AI-generated testing. https://katalon.com/resources-center/blog/what-is-agentic-qa-the-complete-guide-for-2026

About the Authors

Frequently Asked Questions

INDEX

Share this post

Related blogs