Add Pytest to Google ADK Agents: Finally Pinpoint Exactly Which Step Broke Your AI Agent
Testing AI agents has always been a headache: outputs are non-deterministic, and when something goes wrong, you can't figure out which step caused it. DeepEval just released a native Google ADK integration that enables full end-to-end tracing with just one line of code. It supports both end-to-end and component-level testing, integrates seamlessly with Pytest for CI/CD, and is 100% open source.
Testing AI agents is nothing like testing traditional code.
Traditional code lets you assert on fixed outputs, but AI agents can't do that—every run can produce a different result. What's more, AI agents typically execute across multiple steps: the large language model generates an action plan, tools execute the plan, then the LLM generates the final response. Any step can fail without throwing an explicit error, and when the final result is wrong, you have no idea where to start debugging.
This is a common pain point for developers working with Google ADK (Google's official AI agent development framework), and now open-source LLM evaluation framework DeepEval has solved it.

DeepEval is already the top-ranked LLM evaluation framework on GitHub's daily trending. Its new Google ADK integration brings Pytest into AI agent testing, and the core implementation is incredibly simple: just call `instrument_google_adk()` once, and it automatically generates a complete trace for every agent run. Every model call, tool invocation, and execution step is turned into a standalone, evaluable component span.
This design directly addresses the core pain points of AI agent testing, enabling testing at two levels:
1. End-to-end evaluation: Score the full agent run to check if the task is completed
2. Component-level evaluation: Attach metrics to individual LLM calls or tool invocations, and it tells you exactly which step failed when the test doesn't pass
Community developers have noted that component-level testing is the most valuable part of this solution, and it's a key feature missing from most existing AI agent testing frameworks.
The whole workflow is no different from regular Pytest testing: parameterize your test cases in a golden dataset, run the agent in the test function, then just call `assert_test()` to finish. If metrics don't meet your threshold, the test fails and blocks the build—exactly the same workflow you follow for regular unit testing.
If you don't want to run this in CI, you can just write a simple script to loop through your golden dataset and get scores for every trace without touching Pytest at all.
Here's a summary of the core features:
- Automatic instrumentation with one line of code, no manual changes to your business logic required
- Full end-to-end, agent, LLM, and tool spans all support independent evaluation
- Native Pytest integration for out-of-the-box CI/CD
- Built-in metrics cover common use cases including task completion, answer relevance, faithfulness, G-Eval, and more
- Supports standalone evaluation via scripts, not limited to CI workflows
- Optional Confident AI dashboard for visual trace debugging
The entire project is 100% open source under the Apache 2.0 license, you can find the source code here: [confident-ai/deepeval](https://github.com/confident-ai/deepeval)
Let's look at an example testing a calculator assistant to see what actual output looks like:
```
$ deepeval test run test_google_adk_agent.py
●test_google_adk_agent
│
└─AGENT calculator_assistant Task Completion 0.96✓ 210ms
├─LLM gemini-2.0-flash · plan G-Eval 0.44✗ 82ms
├─TOOL calculate(operation="multiply") 38ms
└─LLM gemini-2.0-flash · respond Faithfulness 0.95✓ 70ms
Trace score 0.78 · 2/3 metrics passed
failed
```
You can see at a glance that the LLM call during the planning step failed, no need to sift through logs line by line yourself.
If you want to try it yourself, installation only takes one command:
```bash
pip install -U deepeval google-adk openinference-instrumentation-google-adk opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
```
Then add just one line of initialization before running your agent:
```python
from deepeval.integrations.google_adk import instrument_google_adk
instrument_google_adk()
```
From there, just write your test cases the same way you normally would with Pytest. You can find the full sample code in the official documentation: [Google ADK Integration | DeepEval](https://deepeval.com/integrations/frameworks/google-adk)
One developer shared an interesting feature request: they want prompt and tool versions recorded for each span to make it easier to diff changes. Even if you can pinpoint where the error is, it's still hard to catch regressions caused by prompt drift or tool contract changes, and this suggestion hits on a real pain point for long-term agent iteration. It'll be interesting to see if the development team adds this feature down the line.
AI agent evaluation has actually long been an underdiscussed topic: everyone talks about building bigger, faster agents, but very few talk about how to test them reliably. Being able to test AI agents using the familiar Pytest workflow that ordinary developers already know is inherently a great direction.
If you're currently building agents with Google ADK, or you're struggling to debug failing AI agents with no way to pinpoint errors, you should give this a try.
发布时间: 2026-07-15 00:32