Backendcore
Testing LLM applications
Unit tests with mocked models, contract tests for tools, property tests for parsers, evals for behaviour.
What it is and why it exists
Deterministic code around the model (parsers, context assembly, tool handlers, permissions) gets ordinary unit tests with the model mocked or replayed from fixtures. Tool schemas get contract tests. Parsers get property-based tests. Model behaviour gets evals — a separate, slower suite with statistical thresholds.
Quick prototype
Manual testing in a chat window.
In production, at scale
Fast unit suite (no network), recorded-fixture integration tests, contract tests between agent and tools, property tests on parsers and chunkers, eval suite in CI with thresholds, load tests against rate limits, and red-team cases.
Vendors and tools
| pytest / pytest-asyncio / respx / vcrpy | Python testing and HTTP mocking |
|---|---|
| Hypothesis | Property-based testing |
| promptfoo / DeepEval | Evals as tests |
How it fails
- Tests that call the live API (slow, flaky, costly)
- Only evals, no unit tests, so a parsing bug looks like model quality
What the interviewer asks next
What would you property-test in a RAG system?
The chunker: concatenating chunks (minus overlap) reproduces the text, no chunk exceeds the size limit, every chunk has its source metadata. The packer: never exceeds the budget.