intermediate·11 min read·Updated

How to Automate API Testing Using AI: Fix with AI (Part 2)

AI can propose a repair for a failing API test, but who decides what changes? Review fixes a rule prepared, fix missing data with a real id, use Fix with AI on one test or a whole cause, and re-run to check.

This is lesson 9.11, part 2, of Shift-Left API in Depth, the product track of the learning center. In part 1, Run Triage grouped a run's failures into causes. Now you repair the causes that a test change can repair. Fix with AI on a test is in every edition of Shift-Left API. Test Run Packs and their full reports come with Professional, Enterprise and the 15-day trial, and the AI parts need an AI provider. The demo calls the sandbox store API, with staged failures.

How to automate API testing using AI and still decide what changes?

The answer to how to automate API testing using AI safely is to treat each fix as a proposal. A fix can come from four places:

  • A rule: a known correction, such as a changed status code. It uses no AI and is ready when the run is analyzed.
  • Another test: a test that lists records supplies a real id, with no AI.
  • AI for a whole cause: one AI call for the group, within the project's budget.
  • AI for one test: Fix with AI in the test editor.

There are limits. Fix with AI never patches a likely product bug or an environment problem. If the target never answered, nothing in that run is repaired. It never rewrites an expected status onto an error code, never turns a test that expects a rejection into one that proves nothing, and drops a change it can't base on evidence.

How do you apply a fix a rule prepared?

  1. Open a Tests out of date cause and click Review fixes.
  2. For each test, compare the old and new expectation and read the reason. Untick anything wrong.
  3. Click Apply. The result shows each test as applied, or left alone if someone edited it since.
  4. Click Done, then Re-run to check. The tests run the normal way, and the cause says how many are fixed and how many still fail.

What if the test data is missing?

A product id that doesn't exist in this environment shouldn't be guessed, and dropping the failing check would hide the problem. An id from an old run may be gone too. Click Fix these tests. In the demo, Shift-Left API names a test that lists products and offers to run it. Click Get a real id: that read-only test runs in Development, and its id becomes a fix you review and apply.

If only a test that creates records could supply an id, it asks first, because that adds a record, and it never does so in production.

How does Fix with AI work on one test?

Open a failing test in the workbench, go to the Assertions tab and click Fix Assertions. The arrow beside the button offers other scopes: everything, data, body, parameters, assertions or authentication.

It reads the test, the API's documented contract, any linked requirement, the last failed run and the run analysis. The answer shows what it thinks is wrong, how sure it is, and each change before and after, with its basis where there is one. Choose Apply to form to check and save yourself, Apply & Save to do both, or Discard to change nothing. A change based only on this run deserves the closest look.

On a likely product bug it refuses and explains why, using the run analysis's verdict. If you disagree, change the verdict in the report and ask again. Diagnostics, under the Request tab of the results, shows what was sent and what decided pass or fail.

Can one AI call fix a whole cause?

Yes. On a cause that allows it, click Fix these tests. One call covers the group and uses anything you told it about the cause. Read each change, untick doubtful ones, apply, then re-run. AI answers vary. If the AI can't be reached or runs out of quota, the cause says so, and you can still edit tests by hand.

Where are the settings?

Go to Project Settings, then AI Generation, then Failing tests. The figures for the last 30 days include fixes accepted and fixes that held. Grouping uses no AI. The plain-language summary, automatic investigation and whole-cause fixes spend AI calls. AI calls per run sets the ceiling, spent on the biggest causes first, and rule-made fixes don't count. Anyone who can see runs can read causes. Fixing, applying and filing a defect need permission to edit tests. Filing also needs a connected ticket tracker.

Try it yourself

Apply a rule-made fix and re-run it. Then fix missing data with a real id, use Fix with AI on one test, and fix one whole cause.

Recap

  • Let rules fix what they can, and take missing ids from real records.
  • Read each AI change and its basis before you apply it.
  • Fix environment causes first, and send likely bugs to the API's owners.
  • Re-run to check after you apply.

Next, in lesson 9.12, you step back from one run to all of them. Read the help page on Fix with AI for more detail.

Hands-on lab

Try it: With a trial edition, review a rule-made fix on a run report, apply it and re-run to check. Fix missing test data with a real id, use Fix with AI on one failing test, then fix a whole cause and re-run.

Enter your email to open the lab steps. One unlock opens every lab in the learning center.

No spam. Protected by reCAPTCHA — Google Privacy & Terms.

Frequently asked questions

Does AI change failing tests automatically in this workflow?+

In the workflow shown here, no. Every fix is a proposal that you review, and nothing changes until you apply it. After applying, you re-run the tests to check that the fix holds.

What does AI test repair refuse to do?+

Fix with AI never patches a likely product bug or an environment problem, and repairs nothing in a run whose target never answered. It never rewrites an expected status onto an error code, never turns a test that expects a rejection into one that proves nothing, and drops a change it can't base on evidence.

Which edition do you need to automate API testing with AI fixes?+

Run Triage, and Fix with AI on a test, are in every edition. Test Run Packs and their full reports come with Professional, the 15-day trial and Enterprise. The AI parts need an AI provider, and on the trial AI fixes count toward a daily limit.

Read more on the blog