Skip to content

Conversation

@alexbond85
Copy link

@alexbond85 alexbond85 commented Nov 21, 2025

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

- 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.
@adk-bot adk-bot added the tools [Component] This issue is related to tools label Nov 21, 2025
@adk-bot
Copy link
Collaborator

adk-bot commented Nov 21, 2025

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!

- 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
@alexbond85 alexbond85 marked this pull request as ready for review November 21, 2025 11:31
@ryanaiagent ryanaiagent self-assigned this Nov 21, 2025
@ryanaiagent
Copy link
Collaborator

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 ryanaiagent added the request clarification [Status] The maintainer need clarification or more information from the author label Nov 30, 2025
alexbond85 and others added 2 commits December 3, 2025 16:02
- 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)
@alexbond85
Copy link
Author

@ryanaiagent done

@ryanaiagent ryanaiagent added needs-review [Status] The PR is awaiting review from the maintainer and removed request clarification [Status] The maintainer need clarification or more information from the author labels Dec 3, 2025
@ryanaiagent
Copy link
Collaborator

Hi @DeanChensj , can you please review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review [Status] The PR is awaiting review from the maintainer tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants