Fleet 1.13:Teams are now shipping 5x more PRs with autonomous pipelines.See what's new →
FleetFleet
Use case

AI Agents for Test Generation

Test coverage gaps accumulate in every codebase. New code ships with insufficient tests because writing thorough tests takes time and slows velocity in the short term. The deferred cost is paid later in bugs that reach production and slow, risky deploys.

The specific challenge with test generation is that it requires understanding the intent of the code, not just its structure. A test that merely achieves line coverage but does not test meaningful behavior provides false confidence. Good tests verify behavior under edge cases, with unexpected inputs, and across error paths.

How it works with an agent fleet

A test-generation agent analyzes code with low coverage and writes tests that cover meaningful behavior, including edge cases and error paths.

agents:
  - name: test-writer
    role: qa-engineer
    model: claude-opus-4-7
    subscribes_to: pr_needs_review

The agent's prompt lives at .fleet/prompts/test-writer.md — Fleet resolves it by convention from the agent name, so there is no prompt: field in config. The test-writer prompt instructs the agent to run your coverage tool, identify uncovered paths in changed files, and write tests that exercise those paths. The agent commits the tests to the PR branch so they go through review alongside the implementation.

The fleet pattern

Test generation runs as part of the PR review chain. The qa-engineer agent checks coverage on every PR and adds tests when it finds gaps. This means test coverage improves incrementally with every merge rather than requiring a dedicated refactoring sprint.

Guardrails that matter here

  • Generated tests are added to the PR branch and reviewed before merge — not auto-merged
  • Agent prompt specifies your test framework and conventions so generated tests match the codebase style
  • Tech-lead reviews test quality in the same PR review pass, flagging tests that check syntax rather than behavior

Who this is for

Teams that want coverage to improve incrementally over time without a dedicated test-writing sprint. Also useful when onboarding a new codebase with poor test coverage and wanting to establish baseline coverage before making changes.

Frequently asked questions

Will the agent write tests for code it did not write?

Yes. You can assign a test-generation task pointing at any file or package. The agent reads the code, infers intent from function names and comments, and writes tests. A human should review the inferred intent before the tests are merged.

Can the agent mock dependencies when writing tests?

Yes, if you describe your mocking approach in the agent prompt. Specify which mocking library you use and show an example of your test structure. The agent follows the pattern.

Run your first agent fleet

One binary. Five minutes. See every agent, coordinate every handoff, and keep a full audit trail of what your fleet did.