Repository navigation
[Microsoft.Android.Run] Support MTP server-mode discovery - #13409
Draft
simonrozsival wants to merge 5 commits into
Draft
simonrozsival wants to merge 5 commits into
simonrozsival wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved defects can break discovery for generic-parameter tests or normal adb startup, prevent large test selections from launching on Windows, and fail host tests when work-directory paths contain spaces.
4 open issues
What changed in this PR
Adds public Microsoft.Testing.Platform (MTP) server-mode discovery and selected-test execution to the Android launcher, enabling compatible IDE clients while preserving the existing dotnet test transport and opaque test UIDs.
Changes:
- Adds JSON-RPC server options, discovery requests, UID filtering, and method metadata.
- Updates NUnit instrumentation and the MSTest template for discovery without execution, including Release trimming support.
- Adds host protocol regressions, device-template coverage, and usage documentation.
| File | Description |
|---|---|
tests/TestRunner.Core/TestInstrumentation.cs |
Adds NUnit discovery, UID filtering, and method metadata. |
tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs |
Covers template discovery and selected execution, including Release discovery. |
tests/Microsoft.Android.Run-Tests/Microsoft.Android.Run-Tests.csproj |
Defines the new host protocol test project. |
tests/Microsoft.Android.Run-Tests/FakeAdb.cs |
Supplies simulated adb responses for host tests. |
tests/Microsoft.Android.Run-Tests/AndroidTestAdapterTests.cs |
Tests discovery, filtering, failures, and JSON-RPC sessions. |
src/Microsoft.Android.Templates/androidtest/TestInstrumentation.cs |
Adds MSTest discovery and richer streamed results. |
src/Microsoft.Android.Templates/androidtest/AndroidTest1.csproj |
Adds the embedded server client and roots the test assembly. |
src/Microsoft.Android.Run/Program.cs |
Accepts public server-mode and console discovery arguments. |
src/Microsoft.Android.Run/Microsoft.Android.Run.csproj |
Exposes internals to the host tests. |
src/Microsoft.Android.Run/InstrumentationProtocol.cs |
Defines discovery metadata and encoded UID transport. |
src/Microsoft.Android.Run/AndroidTestAdapter.cs |
Handles discovery, selected execution, and metadata publication. |
NuGet.config |
Adds the test-tools package feed. |
Microsoft.Android.slnx |
Includes the host protocol test project. |
Documentation/workflow/UnitTests.md |
Documents discovery support and deployment prerequisites. |
.github/skills/tests/references/test-catalog.md |
Lists the standalone host test command. |
Review effort: Balanced
This was referenced Nov 15, 2026
Enable IDE clients to discover and execute on-device tests through the public MTP JSON-RPC server protocol. Preserve the existing dotnet test transport and forward selected test UIDs without changing their identity. Add discovery and method metadata to the NUnit instrumentation and MSTest template, preserve test assemblies under trimming, and cover the host protocol and generated applications with regression tests. Co-authored-by: Copilot App <[email protected]>
Use matching MSTest and MSTest.SourceGeneration 4.4.1 packages in ReflectionFree mode instead of rooting the complete test assembly. Verify trimmed discovery and execution, individual data-row selection, and removal of unrelated code. Co-authored-by: Copilot App <[email protected]>
Transfer large test selections through a device file, tolerate benign adb discovery output, and match MSTest managed parameter names. Add host and device regressions, including fake adb paths with spaces. Co-authored-by: Copilot App <[email protected]>
Ignore adb informational stderr after successful discovery and align the streaming test fixture with the current discovery event contract. Co-authored-by: Copilot App <[email protected]>
simonrozsival
force-pushed
the
simonrozsival-mtp-server-mode
branch
from
November 21, 2026 13:15
3ce7ccf to
d9790ef
Compare
Reuse the embedded MTP client and discovery protocol now present on main, while retaining public server mode, selected-test execution, and discovery metadata. Remove the obsolete NUnit instrumentation and NuGet feed changes. Co-authored-by: Copilot App <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Context: #13531, #13434
The Android test launcher supports
dotnet testdiscovery and execution, but IDEs using the public Microsoft.Testing.Platform JSON-RPC server protocol also need discovery metadata and selected-test execution. Add server mode and forward selected test UIDs to theandroidtestinstrumentation using the embedded MTP client already present on main.Preserve the existing discovery event and compatibility with older APKs for unfiltered discovery. Selected execution requires an updated APK; the launcher probes for selection support before executing. Larger selections are transferred through an app-specific file. The template uses MSTest source generation in
ReflectionFreemode to preserve test metadata under trimming, and each test class must have[TestClass]directly rather than inheriting it. Build, installation, and device selection remain client responsibilities.Validation:
dotnet test tests/Microsoft.Android.Run-Tests/Microsoft.Android.Run-Tests.csproj -v minimal— passed, 24 tests.dotnet test tests/Xamarin.Android.Tools.AndroidSdk-Tests/Xamarin.Android.Tools.AndroidSdk-Tests.csproj -v minimal -p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=10.0 --filter 'FullyQualifiedName~StreamingTests'— passed, 16 tests.make prepare CONFIGURATION=Debug MSBUILD_ARGS='-m:4' && make leeroy CONFIGURATION=Debug MSBUILD_ARGS='-m:4'— passed../dotnet-local.sh build tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj -v minimal -p:EnableSourceControlManagerQueries=false -p:EnableSourceLink=false— passed.EnableSourceControlManagerQueries=false EnableSourceLink=false ADB_TARGET='-s emulator-5556' ./dotnet-local.sh test bin/TestDebug/MSBuildDeviceIntegration/net11.0/MSBuildDeviceIntegration.dll --filter 'Name~DotNetNewAndroidTest&Name~generic' -v minimal— passed, 2 tests. A wider device run initially passed 12 of 14 cases; its two generic cases failed on an incorrect expected discovery count and passed after correcting the assertion.