|
|
Building an End-to-End ADK Agent Test Suite
Author: Venkata Sudhakar
A production-grade ADK agent test suite for ShopMax India combines unit tests, integration tests, and performance assertions in a single pytest file. Unit tests verify individual helper functions in isolation. Integration tests run the full agent pipeline with a mocked LLM. Performance tests check token budgets and response latency. Organising all three levels in one suite makes it easy to run the full check in a single pytest command during CI.
pytest fixtures centralise shared test state: shopmax_context holds the agent configuration and latency budgets, mock_llm returns a preconfigured AsyncMock with realistic token metadata, and sample_order_query provides a standard input string. Each test function declares only the fixtures it needs, keeping tests focused and independent without duplicating setup code.
The example below builds a complete ShopMax India agent test suite with six tests covering order ID extraction, token budget enforcement, response content, order ID presence in the reply, latency measurement, and empty query fallback handling.
It gives the following output,
...... (6 passed in 0.02s)
In production, extend the suite by adding a conftest.py that spins up a real InMemoryRunner for integration tests and keeps the mocked tests in a separate unit test file. Tag tests with pytest.mark.unit, pytest.mark.integration, and pytest.mark.performance so you can run each tier independently in CI. Make this suite the gate for every pull request touching the ShopMax India agent codebase so that regressions in token usage, response quality, or latency are caught before merge.
|
|