Feat/public testing utilities
Summary
Exposed internal testing utilities as public API in google.adk.testing module for PyPI distribution.
What Was Done
Created src/google/adk/testing/ module:
-
testing_utils.py- Core utilities (MockModel, InMemoryRunner, TestInMemoryRunner, helper functions) -
__init__.py- Public API exports
Modified tests/unittests/testing_utils.py:
- Now re-exports from public module for backward compatibility
Key APIs
-
MockModel- Returns predefined responses without LLM API calls -
InMemoryRunner- Runs agents with in-memory services -
TestInMemoryRunner- Async-focused test runner - Helper functions:
create_test_agent(),simplify_events(),create_invocation_context()
Usage
from google.adk.testing import MockModel, InMemoryRunner
agent = Agent(
name="test",
model=MockModel.create(responses=["test response"]),
instruction="test instruction"
)
runner = InMemoryRunner(root_agent=agent)
events = runner.run("input")
Compatibility
No breaking changes - all existing tests work unchanged.
Testing Plan
uv sync --extra test --extra eval --extra a2a && pytest tests/unittests - all tests run successfully
Associated Issue
Decided not to raise and issue, implemented it directly instead
Response from ADK Triaging Agent
Hello @alexbond85, thank you for your contribution!
To help us review this PR, could you please address the following points from our contribution guidelines?
- Associated Issue: For new features, please create an issue that describes the feature and associate it with this PR.
- Testing Plan: Please add a "Testing Plan" section to your PR description explaining how you have tested these changes.
You can find more details in our contribution guidelines.
Thank you!
Hi @alexbond85, Thank you for your contribution! We appreciate you taking the time to submit this pull request. Before we proceed with the review can you fix the failing tests.
@ryanaiagent done