Test generation

Detect missing test coverage after each review, then commit AI-generated specs to your branch from GitHub or GitLab.

Live on GitHub & GitLab

Available on workspaces with auto-fix enabled (Free and paid plans within your review limits). After a review, MergeGuard flags changed source files without matching test updates and lets you generate specs in one step.

What triggers detection

After each automated review (not on MergeGuard's own test or auto-fix commits), MergeGuard compares changed files in the PR/MR diff against common test naming patterns—*.test.ts, *.spec.tsx, *_test.go, __tests__/, and similar paths.

  • Create — source changed, no matching test file in the repo → MergeGuard can add a new spec.
  • Extend — source changed, test file exists but was not updated → MergeGuard adds cases to the existing spec only.

What you see on the PR or MR

When gaps are detected, the MergeGuard review summary stays focused on code findings. A separate Missing test coverage comment is posted right after the review with the gap list and an interactive checkbox to use the agent to generate tests.

How to generate tests

Either:

  • Tick Use agent to generate tests in the comment below the review, or
  • Reply @mergeguards generate-tests on the PR/MR conversation.

MergeGuard analyzes up to three files per run, generates tests with AI, and commits them to your branch with a MergeGuard tests: commit prefix. Re-run @mergeguard-followup to refresh the review after new specs land.

Commands & aliases

CommandGitHubGitLab
@mergeguards generate-testsPR Conversation or review summaryMR Overview or review summary

Aliases: @mergeguard, /mergeguards, /mg. Full list: Command reference.

Plans & availability

RequirementDetails
Workspace planSame entitlement as @mergeguards fix (included on Free within caps; Pro/Team for higher limits)
PlatformsGitHub pull requests and GitLab merge requests
Auto re-reviewTest-gen commits do not trigger a full automatic re-review—use follow-up when you want a fresh scan

See Plans & limits and pricing.

Troubleshooting

  • No test coverage section — Every changed source file may already have a matching test update in the diff, or the PR was updated by a MergeGuard automation commit.
  • Checkbox does nothing — On GitHub, the App needs Pull request reviews events (including edited) so checkbox edits on the review body are delivered. On GitLab, note update events must reach the webhook.
  • Generation skipped a file — Very large source or test files, low model confidence, or no concrete gap on the latest head are skipped with a short reason in the review summary.