-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Feat/public testing utilities #3654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add google.adk.testing module with MockModel, InMemoryRunner, and test helpers - Export testing utilities from src/google/adk/testing/ for PyPI distribution - Update tests/unittests/testing_utils.py to re-export from new public location - Add comprehensive README with examples and best practices - Maintain backward compatibility for existing ADK tests This makes testing utilities officially supported and available to ADK users via the PyPI package, enabling easier unit testing of custom agents without requiring real LLM API calls.
|
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?
You can find more details in our contribution guidelines. Thank you! |
- Export RunConfig, Event, LlmRequest, LlmResponse, Session from testing module - Tests access these types via testing_utils.Type (e.g., testing_utils.RunConfig) - Use relative imports in src/ per ADK style guide - Maintains full backward compatibility for all existing tests
|
Hi @alexbond85, Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
- Add 'from __future__ import annotations' to testing_utils.py - Fix import sorting in testing files and samples - Fix pyink formatting (add missing newline at EOF)
|
@ryanaiagent done |
|
Hi @DeanChensj , can you please review this. |
Summary
Exposed internal testing utilities as public API in
google.adk.testingmodule 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 exportsModified
tests/unittests/testing_utils.py:Key APIs
MockModel- Returns predefined responses without LLM API callsInMemoryRunner- Runs agents with in-memory servicesTestInMemoryRunner- Async-focused test runnercreate_test_agent(),simplify_events(),create_invocation_context()Usage
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 successfullyAssociated Issue
Decided not to raise and issue, implemented it directly instead