Skip to content

Write a test with an agent

A coding agent can do everything in Write your first test for you. It works through Belay’s MCP server, as you, with your role’s permissions.

Start as in Write your first test: give Belay your application’s address, and it makes a project with one environment, Default. On the project’s dashboard, choose Write it with my agent. Three steps open under it.

An agent can also make the project itself (create_project, create_environment), when you would rather tell it the address in your prompt.

Add the server to your agent lists Belay’s MCP address and, for each agent, how to add it: a command to copy for Claude Code, Codex, and Gemini CLI, an Add to Cursor link, and what to do in VS Code or any other agent. Each value has a Copy button. Connect an agent has the same list and what happens next.

Give it a first prompt holds a prompt with the project’s name and its address already in it. Type what the test should check under What should your first test check?, and the prompt changes as you type. Left empty, it asks for a test of the most important thing the site does. For a project named “Switchback Cycles”:

Use Belay’s MCP tools to write a first test for the project “Switchback Cycles” at https://switchback.belayqademo.com/. It should check that a helmet can be added to the cart. Save it as a workflow, run it, and tell me the result.

Copy it, and paste it into your agent. What you type there is not kept.

Connection says “Waiting for your agent’s first call to Belay…” until your agent has called Belay at least once, as you, and then “Your agent is connected.” Once a workflow is saved in the project, by your agent or by anyone else, it says “This project has its first workflow,” with the workflow’s name as a link.

The page checks every few seconds while it is open. After ten minutes it stops and says your agent hasn’t called Belay yet; choose Check again to look again.

Connected is about you, not the project: once your agent has called Belay, a project you make later shows it connected from the start.

Given the prompt, the agent:

  1. Finds the project (list_projects, list_environments).
  2. Saves the workflow (save_workflow). Belay reads every step and tells the agent how it understood each one, or what a step needs before it can run.
  3. Rewrites any step that needs a change and saves again.
  4. Starts a run (start_run) and follows it (get_run) until it finishes.
  5. For a step that did not pass, reads why (get_step_evidence) before changing anything.

Everything the agent makes is in your organization. Open the project to see the workflow in the editor and the run with its screenshots. You can edit the steps yourself, and the agent can pick up from your edits.

Agents do well with a few standing instructions:

  • One action or check per step. A step that does two things needs a change before the workflow can run.
  • Read each step’s reading. save_workflow returns one sentence per step saying what Belay will do or check. If it checks less than the step says, rewrite the step.
  • Don’t rerun to make a test pass. Runs are limited, and a pass on a second try hides whatever made the first one stop. Read why the step did not pass first. The one exception is a run whose outcome is interrupted: Belay could not finish it, so running it again is right.
  • A failing test can be a correct test. When the application really does the wrong thing, the workflow should fail until the application is fixed. Ask the agent to report such a failure, not to loosen the check until it passes.

The authoring loop describes each stage, and MCP tools lists every tool.