Core Concepts
Foundational principles of agent unit testing frameworks.
Isolated Mocking
Intercept LLM calls or API boundaries using libraries like `unittest.mock` or `pytest-mock` to test structural logic without burning real API credits.
HTTP Interception
Mock external HTTP endpoints called by agent tools using `respx`, mapping specific URL queries to static JSON payloads cleanly.
Parameterized Tests
Execute a single test case across a dataset matrix using `@pytest.mark.parametrize` to check multiple tool outputs quickly.
Semantic prompt check
Assert that prompt templates are built correctly. Validate that input attributes are correctly formatted into strings.
Exception Verification
Assert that agents fail gracefully when tools return network timeout codes, database failures, or rate-limit warnings.
Schema Compliance
Validate output JSON properties against strict Pydantic model configurations in test assertions to enforce structure.
Setup & Installation
Configure pytest packages in your development workspace.
Install testing packages
Agent Test Code Example
Parameterized tests, mocking HTTP requests via respx, asserting exceptions, and checking prompt formatting.