Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Microsoft Agents Testing

PyPI version

Testing utilities for the Microsoft 365 Agents SDK for Python. This package provides an in-memory channel adapter, fluent conversation assertions, and a mock user-token client so agent behavior can be tested without a live channel or token service.

Release Notes

Version Date Release Notes
1.9.0 2026-10-19 1.9.0 Release Notes
1.8.0 2026-10-01 1.8.0 Release Notes
1.7.0 2026-09-17 1.7.0 Release Notes
1.5.0 2026-08-26 1.5.0 Release Notes

Features

  • TestAdapter runs activities through the normal middleware and agent pipeline while capturing outgoing activities in memory.
  • TestFlow provides fluent helpers for sending activities and asserting replies in order.
  • MockUserTokenClient supports stored tokens, magic codes, sign-out, token status, and token-exchange scenarios.
  • Async-first APIs work with the SDK's standard TurnContext and ChannelAdapter abstractions.

Installation

pip install microsoft-agents-testing

Quick Start

import pytest

from microsoft_agents.hosting.core import TurnContext
from microsoft_agents.testing import TestAdapter, TestFlow


@pytest.mark.asyncio
async def test_echo_agent():
    adapter = TestAdapter()

    async def on_turn(context: TurnContext):
        await context.send_activity(f"Echo: {context.activity.text}")

    await (
        TestFlow(adapter, on_turn)
        .send("hello")
        .assert_reply("Echo: hello")
        .assert_no_more_replies()
        .start_test()
    )

Reply Assertions

Replies can be matched by exact text, partial text, activity properties, or a custom synchronous or asynchronous validator:

from microsoft_agents.activity import Activity, ActivityTypes


def validate_reply(reply: Activity):
    assert reply.type == ActivityTypes.message
    assert reply.text is not None
    assert reply.text.startswith("Hello")


await (
    TestFlow(adapter, on_turn)
    .send("hi")
    .assert_reply_contains("Hello")
    .send("details")
    .assert_reply(validate_reply)
    .start_test()
)

TestFlow also supports conversation updates, typing indicators, delays, mixed activity transcripts, and configurable reply timeouts.

Testing OAuth Flows

TestAdapter uses MockUserTokenClient by default. Add a token to test an already-authenticated user:

adapter = TestAdapter(channel_id="msteams")

adapter.add_user_token(
    connection_name="my-connection",
    channel_id="msteams",
    user_id="user1",
    token="test-token",
)

Token exchange can be configured in the same way:

adapter.add_exchangeable_token(
    connection_name="my-connection",
    channel_id="msteams",
    user_id="user1",
    exchangeable_item="exchange-token",
    token="exchanged-token",
)

These tokens are stored only in memory and are intended exclusively for tests.

Scope

The adapter models the turn-processing boundary needed by unit tests. It does not contact Connector Service, create real proactive conversations, or emulate channel-specific delivery behavior.

Metadata

Release files for microsoft-agents-testing 1.10.0.dev2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microsoft-agents-testing 1.10.0.dev2
File Size Uploaded Provenance Actions
microsoft_agents_testing-1.10.0.dev2.tar.gz 16.3 kB Without provenance Details for microsoft_agents_testing-1.10.0.dev2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for microsoft-agents-testing 1.10.0.dev2
File Interpreter ABI Platform Actions
microsoft_agents_testing-1.10.0.dev2-py3-none-any.whl Python 3 none any Details for microsoft_agents_testing-1.10.0.dev2-py3-none-any.whl

Total release size: 34.2 kB

Release files / microsoft_agents_testing-1.10.0.dev2.tar.gz

Download URL microsoft_agents_testing-1.10.0.dev2.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
411b0db2238303c68c6f63bddd58f69218a58e44093d51498132c2c607f57722
BLAKE2b-256 checksum
How to use checksums
c24b02e11b0bd7945be7d170fc964eccedbf20a55b17b5a3bf226ab7d17d32ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / microsoft_agents_testing-1.10.0.dev2-py3-none-any.whl

Download URL microsoft_agents_testing-1.10.0.dev2-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aaeeb6f6cdb7d2ddcc7de9121f3a04e12fbbb7c7fc7cf6c74fee3285b4b78495
BLAKE2b-256 checksum
How to use checksums
128837067a0bd22369c46df502a93167f6ce04d2c08ce81d4026fa4ab2b7a6da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for microsoft-agents-testing 1.10.0.dev2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page