$1 First: Pick a Model for Unit Test Generation
Start with a $1 trial budget for choosing a model to generate unit tests. That is a spending limit you set, not a promise about how many tests $1 buys. Your language, prompt length, model rates and repair attempts all affect the result. The useful question is simple: how much does it cost to get tests you can trust?
01 / Divide your $1 before sending a prompt
Allocate $0.25 to an initial comparison, $0.50 to repairing and checking the better candidate, and $0.25 as a reserve. These are planning limits, not provider prices or an automatic spending cap. Check usage after each request and stop before your next request could exceed the remaining budget.
On CheapRelay, billing is per real token, including cache reads and writes, with no monthly fee or subscription. Check the current rates before choosing candidates. A short reply can still cost more than expected if you repeatedly send a large source file.
02 / Compare two candidates on three small functions
Put Gemini 2.5 Flash and DeepSeek V4 Flash on your shortlist, then compare their current prices. Their names alone do not establish which will produce better tests for your code. If your budget only supports trying one, start with the lower estimated request cost.
Select three small functions from your project: one with straightforward arithmetic, one with a boundary condition, and one that raises an error or uses a dependency. Avoid starting with a database integration or a function that needs half your application to run.
Give each candidate the same source, requirements and testing framework. Limit the request to five focused tests per function. This produces a small batch you can inspect instead of a large test file that consumes your budget during repairs.
03 / Write the expected behavior before requesting tests
A model cannot reliably infer your intended behavior from implementation alone. If the implementation contains a bug, generated tests may simply preserve it. Supply a short contract alongside the code.
For example, suppose shipping_cost(subtotal) should return 5 below a subtotal of 50 and 0 at or above 50, while rejecting negative values. State those rules explicitly. Useful cases include 0, 49.99, 50, a larger amount and a negative input. Use the numeric type your application actually supports.
Your prompt can say: “Write unit tests using this project's existing framework. Follow the supplied requirements. Cover normal behavior, boundaries and errors. Do not change production code, add dependencies or invent interfaces. Return only the test file.” Include a nearby test as a style example if one exists.
04 / Score assertions before counting passing tests
Run generated tests locally, then inspect what they prove. A green result only shows that the assertions passed against the current implementation. An assertion that a return value exists may miss an incorrect shipping charge.
- ■ Do the tests run with the project's existing command?
- ■ Do expected values come from the stated requirements?
- ■ Are boundaries and error paths checked explicitly?
- ■ Do mocks match real interfaces and preserve meaningful behavior?
- ■ Would an obvious bug cause a test to fail?
Check that last point in a disposable copy: change the shipping threshold from 50 to 51 and rerun the tests. The case at 50 should fail. Restore the code afterward. This single deliberate change gives useful evidence, though it does not prove complete coverage.
05 / Choose using the bill after one repair
Allow each candidate one repair attempt using the actual failure output. Record its total API charge, the tests you kept and your editing time. Divide the charge by the number of useful tests retained. Treat that result as a measurement of this small trial, not a universal benchmark.
Choose the candidate that produces useful tests within your budget and requires tolerable cleanup. Keep the successful prompt for your next batch. Sign up for CheapRelay when you are ready to run the comparison through one API key and its OpenAI-compatible interface. Continue with small functions, checking each batch before spending on the next.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-28 | Model price-offs | EN | $1 Budget: Let Opus Plan and Haiku Type A beginner workflow for splitting planning and drafting between two models, with a $1 spending envelope and clear stopping rules. |
| 2026-10-28 | Model price-offs | EN | $0.50 to Test Grok 4.7 and GPT-5.6 Sol A tiny-budget walkthrough for comparing Grok 4.7 and GPT-5.6 Sol by cost per usable idea, with a reusable prompt and honest cost math. |
| 2026-10-28 | Model price-offs | EN | A $5 Test Budget for GLM-5.3 and Qwen3.8 Max Test GLM-5.3 and Qwen3.8 Max for a Chinese-language app with a $5 spending ceiling, honest token math, and a small evaluation set. |
| 2026-10-28 | Model price-offs | EN | $0.10 Test Budget: Kimi K3 and Claude Sonnet 5 Estimate long-document cost per page, compare Kimi K3 with Claude Sonnet 5, and test both without committing a large budget. |
| 2026-10-28 | Model price-offs | EN | $1 Cap for 1,000 Text Jobs: Check the Receipt A tiny-budget walkthrough for bulk text work with DeepSeek V4 Flash and DeepSeek V4 Pro, using token math, a pilot run and a clear spending cap. |
| 2026-10-27 | Model price-offs | EN | $1 Trial Budget: Claude Haiku 4.5 as Your Default Test Claude Haiku 4.5 on a $1 planning budget, measure real token costs, and learn which everyday jobs need a stronger model. |