Workflow guide · 3 tools
How to write unit tests with AI
AI can draft the repetitive parts of a test, but it cannot decide what your code should do. Give it the public contract, a nearby test to follow and a concrete input that should fail today.
Compare the tools
| Tool | Best for | Tradeoff |
|---|---|---|
| Qodo | Drafting unit tests from an existing function and surfacing scenarios you might miss. | Suggestions can encode current behavior, including bugs, unless you state the contract explicitly. |
| GitAuto | Adding tests to a GitHub repository through an automated PR workflow. | GitHub-only; the team still needs to review the new tests and decide if the added coverage is meaningful. |
| GitHub Copilot | Drafting a small regression test alongside the source in your editor. | May infer fixture or assertion conventions incorrectly when it has too few examples. |
A practical workflow
- Write down one behavior and its expected result. Add a boundary case or error path before asking the tool for fixtures and assertions.
- Run the test against the buggy code or deliberately break the behavior to make sure the assertion fails for the right reason.
- Review mocks and edge cases, then run the whole suite. Prefer a few meaningful assertions over a coverage boost with no new protection.
Try one on your project
-
Qodo
Give it a function with a boundary condition and ask for cases where output or error behavior differs, not more variations of the happy path.
-
GitAuto
Start with one low-coverage module. Review the generated PR for useful assertions, unnecessary mocks and unrelated edits.
-
GitHub Copilot
Open the closest test file and describe the expected failure; let Copilot draft a case, then run it before changing implementation.