|
|
Test Coverage Measurement for ADK Agent Tools
Author: Venkata Sudhakar
ShopMax India's ADK agent toolset includes order lookup, inventory check, return initiator, and EMI calculator - each with multiple code paths. Measuring test coverage for these tool functions tells the engineering team which branches are exercised by the test suite and which are not, preventing silent failures in production paths like a Mumbai warehouse outage handler that was never tested because coverage reports showed the happy path at 100 percent.
Use pytest-cov to measure line and branch coverage for ADK tool functions. Run coverage with --branch to detect conditional paths that are never exercised. Set a minimum coverage threshold in pyproject.toml or setup.cfg to fail the CI pipeline if coverage drops below the target. Focus coverage enforcement on tool modules rather than the full agent codebase - tools contain the deterministic business logic that is most valuable to test exhaustively.
The example below defines a ShopMax India order lookup tool with three branches: found, not found, and warehouse error. Three tests cover all branches. The coverage report output shows 100 percent branch coverage. A fourth test demonstrates what a missing branch looks like in the coverage summary.
It gives the following output,
Branches exercised: 3 of 3
.... (4 passed in 0.01s)
In production, ShopMax India should enforce 90 percent branch coverage for all tool modules using the fail_under setting in .coveragerc. Run coverage in CI with pytest --cov=tools --cov-branch --cov-fail-under=90 so that any new uncovered branch blocks the merge. Review the HTML coverage report weekly to identify complex tool functions with many uncovered error paths - these are the most likely source of silent production failures during high-traffic sale events.
|
|