Skip to content

[tests] Migrate Android runtime tests to MSTest/MTP - #13434

Merged
jonathanpeppers merged 10 commits into
mainfrom
simonrozsival-mstest-delivery-host-ci
Nov 17, 2026
Merged

jonathanpeppers merged 10 commits into
mainfrom
simonrozsival-mstest-delivery-host-ci

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Context: https://learn.microsoft.com/dotnet/core/testing/unit-testing-with-dotnet-test
Context: https://github.com/microsoft/testfx/blob/88a31ec394abe9f5c5dcf596f0a150ff998d3a0e/docs/source-generator/design.md
Context: #13432
Context: #13433

The on-device runtime tests (Mono.Android.NET-Tests, its Java.Interop-Tests fixtures, and Xamarin.Android.JcwGen-Tests) run NUnit through TestRunner.Core. NUnit discovers and invokes tests via reflection, which fights trimming and NativeAOT. To keep it working, the test app roots entire assemblies (<TrimmerRootAssembly RootMode="All"/> for Mono.Android.NET-Tests and Java.Interop-Tests), sets IlcGenerateCompleteTypeMetadata=true, and ships a NativeAOT.rd.xml whose only purpose is to keep NUnit's own reflection alive:

  • EquatablesComparer.GetEquatableImplementations() calls GetGenericArguments()[0] on closed IEquatable<T> instantiations whose metadata ILC otherwise trims, and
  • TaskAwaitAdapter+GenericAdapter<VoidTaskResult> is built via Type.MakeGenericType() for every async Task test.

That is, we were testing a trimmed app whose trimming had been substantially turned off for the benefit of the test framework.

Migrate these suites to MSTest running natively on Microsoft.Testing.Platform (MTP), with MSTest.SourceGeneration emitting the test registry and invocation delegates at compile time.

Android runtime tests

  • Add tests/TestRunner.MSTest.Android, an Android Instrumentation that hosts MTP in-process, registers the fixture assemblies via AddMSTest, applies IncludeCategories/ExcludeCategories from runtimeconfig.json (and -e include, -e exclude, -e noexclusions true extras), and streams results back through the existing dotnet test Android protocol. Test failures return native exit code 2; infrastructure failures cancel instrumentation instead of reporting an empty successful run.
  • Convert test attributes/assertions to MSTest, preserving each case's method name, data rows, categories and multiplicity. Inherited fixtures now report the concrete test class instead of NUnit's generic declaring class, and JniTypeManagerTests.GetType is renamed to GetTypeFromSignature. Exception assertions keep their original exactness; where NUnit's Assert.Throws semantics differed, the test body was restructured rather than weakened.
  • Remove NativeAOT.rd.xml, IlcGenerateCompleteTypeMetadata, and the whole-assembly roots for Mono.Android.NET-Tests and Java.Interop-Tests.
  • Keep roots that protect product/JNI behavior rather than test discovery: Mono.Android-Test.Library.NET, StartupHook, converter/reflection roots, the JCW whole-app root, and new narrow TrimmerRoots.xml entries for RegisterMeOnNewNativeThreadOne (loaded only by Java name from native code; without it RegisterTypeOnNewNativeThread returns -104) and the three ExportField initializers on ExportStaticField/ExportInstanceField (called only from Java field initialization; without them the generated Java ANSWER field disappears).
  • The generated test registry calls tests that intentionally exercise trim/AOT-unsafe APIs, so Mono.Android.NET-Tests keeps the resulting IL2026/IL2062/IL2111/IL3050 analyzer diagnostics as warnings, matching its existing ILLinkTreatWarningsAsErrors=false policy. All other CI warnings-as-errors diagnostics were fixed in the tests themselves.

The existing apk-instrumentation.yaml CI path is unchanged: it still runs dotnet test from the app directory and passes IncludeCategories=JniReferenceLeak for the dedicated JNI lanes.

Package versions

All migrated suites take their versions from eng/Versions.props: the Maestro-flowed $(MSTestPackageVersion) (4.6.0-preview.26531.5) plus a new testfx dependency in eng/Version.Details.xml for $(MicrosoftTestingExtensionsTrxReportPackageVersion), so TrxReport flows in lockstep with MSTest. Microsoft.Testing.Platform.MSBuild comes transitively from MSTest.TestAdapter. The repo-wide $(MicrosoftTestingPlatformVersion) used by Microsoft.Android.Run is not touched.

Documentation

  • Documentation/workflow/UnitTests.md and the tests skill catalog describe the MSTest suites and their dotnet test commands.

Results

Measured on this branch when it was based on main aa91d328 (Release, full trim, API-35 arm64 emulator, local SDK, -p:_AndroidTreatWarningsAsErrors=true like CI, MSTest 4.6.0-preview.26531.5):

Suite (runtime) Cases Passed Skipped Failed
Mono.Android.NET-Tests (CoreCLR) 1063 1055 8 0
Mono.Android.NET-Tests (NativeAOT) 1000 992 8 0
Xamarin.Android.JcwGen-Tests (CoreCLR) 47 46 1 0

Earlier, on 598780a6, the migrated suites matched a fresh run of the original NUnit suites on the same commit exactly (1046/1038/8, 983/975/8, 47/46/1); the difference comes from tests added on main in between. Later merges from main added further tests, so these counts are not current; validate by comparing identities, categories and multiplicity against NUnit on the same commit, not against fixed totals.

Each was run from its test project directory after ./dotnet-local.sh build -t:Install -c Release [-p:PublishAot=true] <project>, via ../../../dotnet-local.sh test <project> --no-build -c Release [-p:PublishAot=true] --report-trx.

Identities, categories and multiplicities were also compared case by case earlier in development, along with the NTLM opt-in lane.

Azure DevOps build 1679890 on PR head 2b5c5d0f succeeded (later commits are merges from main, which also convert newly merged tests to MSTest, and docs fixes). Its test runs report the same totals as the NUnit baseline build 1679118: Mono.Android.NET-Tests CoreCLR (Debug, Release, NoAab) 1063, NativeAOT 1000, Xamarin.Android.JcwGen-Tests 47, and the JniReferenceLeak lanes 8 (Mono.Android.NET-Tests) and 1 (Xamarin.Android.JcwGen-Tests). Test titles and multiplicities match after name normalization, except for the GetTypeFromSignature rename. The 63 fewer NativeAOT cases are the existing NativeAOTIgnore and SSL exclusions.

On-device execution time was measured but is noisy: median 16.9s (MSTest) vs. 19.2s (NUnit), while repeated runs of the unchanged NUnit app ranged 16.7s–43.4s. This PR does not claim a CI speedup.

Known issues

  • JCW under NativeAOT aborts with SIGABRT (RhFailFast) once JavaAbstractMethodTest starts, under both the original NUnit and the migrated MSTest app. This is pre-existing and not addressed here.
  • MSTest.SourceGeneration still reports incomplete descriptors for some fixtures (generic helpers, inherited members) and retains a bounded reflection fallback; this is not "reflection-free" test execution.
  • JavaMarshalGCBridgeTests.ManagedPeerCycleSurvivesJavaRootAndIsCollectedAfterRelease is intermittent under NativeAOT (missing global-to-weak bridge events): 1 of 3 earlier local runs failed it, the others passed. It was also seen intermittently earlier in development.
  • Local runs used only API-35 arm64 with CoreCLR and NativeAOT. The MonoVM runtime is not exercised.

@simonrozsival simonrozsival changed the title [tests] Add native MSTest host foundations and opt-in CI [tests] Migrate SourceWriter tests to MSTest/MTP with opt-in CI Nov 11, 2026
@simonrozsival
simonrozsival removed this pull request from stack #13435 November 11, 2026 10:07
@simonrozsival simonrozsival changed the title [tests] Migrate SourceWriter tests to MSTest/MTP with opt-in CI [tests] Migrate Android runtime and SourceWriter tests to MSTest/MTP Nov 11, 2026
simonrozsival and others added 2 commits November 11, 2026 13:11
Context: https://learn.microsoft.com/dotnet/core/testing/unit-testing-with-dotnet-test
Context: https://github.com/microsoft/testfx/blob/88a31ec394abe9f5c5dcf596f0a150ff998d3a0e/docs/source-generator/design.md
Context: #13432
Context: #13433

The on-device runtime tests (`Mono.Android.NET-Tests`, its `Java.Interop-Tests` fixtures, and `Xamarin.Android.JcwGen-Tests`) run NUnit through `TestRunner.Core`. NUnit discovers and invokes tests via reflection, which fights trimming and NativeAOT. To keep it working, the test app roots entire assemblies (`<TrimmerRootAssembly RootMode="All"/>` for `Mono.Android.NET-Tests` and `Java.Interop-Tests`), sets `IlcGenerateCompleteTypeMetadata=true`, and ships a `NativeAOT.rd.xml` whose only purpose is to keep NUnit's own reflection alive:

  * `EquatablesComparer.GetEquatableImplementations()` calls `GetGenericArguments()[0]` on closed `IEquatable<T>` instantiations whose metadata ILC otherwise trims, and
  * `TaskAwaitAdapter+GenericAdapter<VoidTaskResult>` is built via `Type.MakeGenericType()` for every `async Task` test.

That is, we were testing a trimmed app whose trimming had been substantially turned off for the benefit of the test framework.

Migrate these suites to MSTest running natively on Microsoft.Testing.Platform (MTP), with `MSTest.SourceGeneration` emitting the test registry and invocation delegates at compile time.

### Android runtime tests

  * Add `tests/TestRunner.MSTest.Android`, an Android `Instrumentation` that hosts MTP in-process, registers the fixture assemblies via `AddMSTest`, applies `IncludeCategories`/`ExcludeCategories` from `runtimeconfig.json` (and `-e include`, `-e exclude`, `-e noexclusions true` extras), and streams results back through the existing `dotnet test` Android protocol. Test failures return native exit code `2`; infrastructure failures cancel instrumentation instead of reporting an empty successful run.
  * Convert test attributes/assertions to MSTest, preserving each case's canonical name, data rows, categories and multiplicity. Exception assertions keep their original exactness; where NUnit's `Assert.Throws` semantics differed, the test body was restructured rather than weakened.
  * Remove `NativeAOT.rd.xml`, `IlcGenerateCompleteTypeMetadata`, and the whole-assembly roots for `Mono.Android.NET-Tests` and `Java.Interop-Tests`.
  * Keep roots that protect product/JNI behavior rather than test discovery: `Mono.Android-Test.Library.NET`, `StartupHook`, converter/reflection roots, the JCW whole-app root, and new narrow `TrimmerRoots.xml` entries for `RegisterMeOnNewNativeThreadOne` (loaded only by Java name from native code; without it `RegisterTypeOnNewNativeThread` returns `-104`) and the three `ExportField` initializers on `ExportStaticField`/`ExportInstanceField` (called only from Java field initialization; without them the generated Java `ANSWER` field disappears).

The existing `apk-instrumentation.yaml` CI path is unchanged: it still runs `dotnet test` from the app directory and passes `IncludeCategories=JniReferenceLeak` for the dedicated JNI lanes.

### SourceWriter host tests

`Xamarin.SourceWriter-Tests` moves to MSTest/MTP as the host-side pilot. A new opt-in `runNativeMtpHostTests` pipeline parameter (default `false`) adds an independent Linux stage that installs `$(DotNetSdkVersion)` and runs:

	DOTNET_TEST_RUNNER=Microsoft.Testing.Platform dotnet test \
	  --project tests/Xamarin.SourceWriter-Tests/Xamarin.SourceWriter-Tests.csproj \
	  -c Debug --report-trx --results-directory $(Agent.TempDirectory)/TestResults

The TRX is published with `PublishTestResults@2` and `failTaskOnMissingResultsFile: true`. MTP selection is scoped to that one step via `DOTNET_TEST_RUNNER`, so every other NUnit suite keeps using VSTest and all existing stages are unchanged; `skipTests` still skips the new stage.

An earlier revision drove this stage through a custom Python adapter (`run-native-mtp-tests.py`) that did UID-based slicing, retried failed tests and rewrote TRX files. For an 11-test suite that was all cost and no benefit, so it was removed in favor of the plain `dotnet test` invocation above: MTP's exit code already fails the step, and the standard Azure task publishes the results.

### Package versions

All migrated suites take their versions from `eng/Versions.props`: the Maestro-flowed `$(MSTestPackageVersion)` (`4.6.0-preview.26531.5`) plus a new testfx dependency in `eng/Version.Details.xml` for `$(MicrosoftTestingExtensionsTrxReportPackageVersion)`, so TrxReport flows in lockstep with MSTest. `Microsoft.Testing.Platform.MSBuild` comes transitively from `MSTest.TestAdapter`. The repo-wide `$(MicrosoftTestingPlatformVersion)` used by `Microsoft.Android.Run` is not touched.

### Documentation

  * `tests/Xamarin.SourceWriter-Tests/README.md` describes how to build, run and filter the MTP suite.
  * `Documentation/workflow/UnitTests.md` and the `tests` skill catalog describe the MSTest suites and their `dotnet test` commands.

### Results

Release, full trim, API-35 arm64 emulator, local SDK built from this branch (`make prepare leeroy CONFIGURATION=Release`), MSTest `4.6.0-preview.26531.5`. NUnit baseline is a fresh run of the original suites on the same `main` (`598780a6`):

| Suite          | Cases | Passed | Skipped | NUnit baseline |
| -------------- | ----: | -----: | ------: | -------------- |
| Mono CoreCLR   |  1046 |   1038 |       8 | identical      |
| Mono NativeAOT |   983 |    975 |       8 | identical      |
| JCW CoreCLR    |    47 |     46 |       1 | identical      |

Each was run from its test project directory after `./dotnet-local.sh build -t:Install -c Release [-p:PublishAot=true] <project>`, via `../../../dotnet-local.sh test <project> --no-build -c Release [-p:PublishAot=true] --report-trx`.

Identities, categories and multiplicities were also compared case by case earlier in development, along with the `JniReferenceLeak` (Mono 6, JCW 1) and NTLM opt-in lanes; those category lanes were not re-run on this head.

`Xamarin.SourceWriter-Tests`: 11/11 passed with SDK `11.0.100-rc.3.26522.148` (the pipeline's `$(DotNetSdkVersion)`) and SDK 12; a filter matching nothing exits `8`, so failures propagate.

On-device execution time was measured but is noisy: median 16.9s (MSTest) vs. 19.2s (NUnit), while repeated runs of the *unchanged* NUnit app ranged 16.7s–43.4s. This PR does not claim a CI speedup.

### Known issues

  * JCW under NativeAOT aborts with `SIGABRT` (`RhFailFast`) once `JavaAbstractMethodTest` starts, under **both** the original NUnit and the migrated MSTest app. This is pre-existing and not addressed here.
  * `MSTest.SourceGeneration` still reports incomplete descriptors for some fixtures (generic helpers, inherited members) and retains a bounded reflection fallback; this is not "reflection-free" test execution.
  * Only API-35 arm64 with CoreCLR and NativeAOT was exercised; the Azure stages have not been run against this revision.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CI builds test projects with TreatWarningsAsErrors.

* Make BaseRocksFixture helpers protected so the MSTest source generator does not treat them as test candidates (AOTSG0004).
* Rename JniTypeManagerTests.GetType, which hid object.GetType (MSTEST0036).
* Use AreNotEqual for JniObjectReference struct comparisons; AreNotSame on boxed structs always passed (MSTEST0038).
* Drop always-true IsNotNull checks on TimeSpan/DateTime; the surrounding DoesNotThrow is the actual assertion (MSTEST0032).
* Keep IL2026/IL2062/IL2111/IL3050 non-fatal in Mono.Android.NET-Tests: the generated test registry calls tests that intentionally exercise trim/AOT-unsafe APIs, matching the existing ILLinkTreatWarningsAsErrors=false policy.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the simonrozsival-mstest-delivery-host-ci branch from 7ea8e50 to 63e8c17 Compare November 11, 2026 12:35
simonrozsival and others added 2 commits November 12, 2026 23:52
…delivery-host-ci

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival marked this pull request as ready for review November 13, 2026 14:59
Copilot AI balanced review requested due to automatic review settings November 13, 2026 14:59
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Android PR Reviewer for #13434

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test catalog’s stale acceptance counts could accept runs missing 20 cases or reject complete runs, so they need to be updated or scoped to the tested commit.

1 open issue
What changed in this PR

Migrates Android runtime, Java.Interop, JCW, and SourceWriter tests from NUnit to MSTest on Microsoft.Testing.Platform (MTP). Generated test registration reduces discovery-related preservation requirements, making trimming and NativeAOT testing more representative.

Changes:

  • Convert fixtures, assertions, data sources, and lifecycle hooks to MSTest.
  • Introduce shared Android runner configuration and replace NUnit-specific trimming workarounds with targeted JNI roots.
  • Add an opt-in SourceWriter CI stage, centrally managed TRX reporting dependency, and updated testing documentation.
File Description
tests/​Xamarin.SourceWriter-Tests/​Xamarin.SourceWriter-Tests.csproj Configure executable MSTest/MTP host tests.
tests/​Xamarin.SourceWriter-Tests/​TypeReferenceWriterTests.cs Convert type-reference tests and null assertions.
tests/​Xamarin.SourceWriter-Tests/​README.md Document host execution, filtering, and CI.
tests/​Xamarin.SourceWriter-Tests/​PropertyWriterTests.cs Convert property-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​MethodWriterTests.cs Convert method-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​InterfaceWriterTests.cs Convert interface-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​FieldWriterTests.cs Convert field-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​EventWriterTests.cs Convert event-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​DelegateWriterTests.cs Convert delegate-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​ConstructorWriterTests.cs Convert constructor-writer test attributes.
tests/​Xamarin.SourceWriter-Tests/​ClassWriterTests.cs Convert class-writer tests; disable assembly parallelism.
tests/​TestRunner.MSTest.Android/​TestRunner.MSTest.Android.csproj Define the shared Android runner library.
tests/​TestRunner.MSTest.Android/​MSTest.Android.props Share MSTest dependencies and execution settings.
tests/​TestRunner.MSTest.Android/​AndroidTestAssert.cs Add a no-exception assertion helper.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.RuntimeTests/​TestInstrumentation.cs Adopt MSTest instrumentation and aliased fixture registration.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.Net/​TrustManagerMarshallingTests.cs Convert trust-manager tests and assertion exceptions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.Net/​AndroidMessageHandlerNegotiateAuthenticationTests.cs Convert authentication tests, categories, and skips.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.Net/​AndroidMessageHandlerIntegrationTests.cs Convert HTTP integration tests and setup.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.Net/​AndroidMessageHandlerCancellationTests.Rewind.cs Convert rewind tests and comparison assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.Net/​AndroidMessageHandlerCancellationTests.cs Convert cancellation tests and lifecycle hooks.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Xamarin.Android.Net/​AndroidHandlerTestBase.cs Convert shared HTTP tests and diagnostics.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​TrimmerRoots.xml Preserve Java/native-only entry points explicitly.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System/​StartupHookTest.cs Convert startup-hook test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System/​AssemblyInformationalVersionAttributeTest.cs Convert assembly-version test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System/​AppDomainTest.cs Preserve exact exception checks in MSTest.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System/​AppContextTests.cs Convert runtime-configuration tests and dynamic data.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Xml/​XmlSerializer.cs Convert XML serialization test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Threading/​InterlockedTest.cs Convert tests and normalize assertion argument order.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Text/​EncodingTests.cs Expose encoding cases through MSTest dynamic data.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Text.Json/​JsonSerializerTest.cs Convert JSON serialization test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Security.Cryptography/​CryptographyTest.cs Convert cryptography tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Runtime.InteropServices/​RuntimeInformationTest.cs Convert runtime-identifier test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Runtime.InteropServices/​DllImportTest.cs Use MSTest and the no-exception helper.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net/​WebSocketTests.cs Convert WebSocket tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net/​SslTest.cs Convert TLS tests, data rows, and skips.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net/​ProxyTest.cs Convert proxy tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net/​NetworkInterfaces.cs Convert interface tests and assertion messages.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net.NetworkInformation/​PingTest.cs Convert ping test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net.NetworkInformation/​NetworkChangeTest.cs Convert network-change test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Linq/​LinqExpressionTest.cs Convert expression tests and null assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.IO/​StreamTest.cs Convert stream test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.IO/​DriveInfoTest.cs Convert drive tests and assertion argument order.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.IO/​DirectoryTest.cs Convert directory test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.IO.Compression/​GZipStreamTest.cs Convert compression tests and no-exception checks.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Drawing/​TypeConverterTest.cs Convert type-converter test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​NativeAOT.rd.xml Remove NUnit-specific NativeAOT reflection directives.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Mono.Android.NET-Tests.csproj Adopt MSTest; remove discovery roots and metadata workarounds.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Localization/​LocalizationTests.cs Convert localization test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Util/​SpliteratorTests.cs Convert spliterator tests and exact exception checks.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Net/​InetAddressTest.cs Convert address tests and type assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Lang/​ObjectTest.cs Convert Java object tests and runtime skips.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​VirtualCallbackConstructorTests.cs Convert callback tests and exception assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​TrimmableTypeMapTestHelpers.cs Switch shared assertion imports to MSTest.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​TrimmableTypeMapExportTests.cs Convert export tests and string assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​TrimmableTypeMapDirectCallbackTests.cs Convert direct-callback tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​PeerIdentityTests.cs Convert peer-identity tests and data rows.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​ManagedObjectProxyTests.cs Convert proxy tests and GC comparisons.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​JniRuntimeExceptionPolicyTests.cs Convert lifecycle, data rows, and test-context logging.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​JniRemappingLookupTests.cs Convert remapping cases and assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​JavaObjectExtensionsTests.cs Convert cast tests; alias cross-assembly fixtures.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​JavaMarshalGCBridgeTests.cs Convert GC-bridge tests and named data rows.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​InvokerActivationTests.cs Convert activation tests and type assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​InterfaceCollectionMarshallingTests.cs Convert collection tests; materialize assertion inputs.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Widget/​CustomWidgetTests.cs Convert widget tests and no-exception checks.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Widget/​AdapterTests.cs Convert adapter tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Views/​LayoutInflaterTest.cs Convert inflater tests and category metadata.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Util/​SparseArrayTests.cs Convert sparse-array tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​XmlReaderResourceParserTest.cs Convert resource-parser test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​XmlReaderPullParserTest.cs Convert pull-parser test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​RuntimeEventSourceTests.cs Convert event tests, exception checks, and skips.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​ManagedObjectReferenceManagerTests.cs Convert reference-tracing cases and collection assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​JavaCollectionTest.cs Convert Java collection test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​InputStreamInvokerTest.cs Convert stream assertions and exact exception checks.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Runtime/​CharSequenceTest.cs Convert character-sequence test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.OS/​HandlerTest.cs Convert handler test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.OS/​BundleTest.cs Convert bundle tests and null assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.OS/​AidlProxyTests.cs Convert AIDL tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Graphics/​NinePatchTests.cs Convert drawable cases to MSTest dynamic data.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Content/​SharedPreferencesTest.cs Convert preferences test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Content/​IntentTest.cs Convert intent test attributes.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Content/​CursorLoaderTest.cs Convert asynchronous loader tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.Content.Res/​AssetManagerTest.cs Convert asset cases to MSTest dynamic data.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.App/​TrimmableTypeMapManifestTests.cs Convert manifest-rooting tests and categories.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.App/​NotificationTests.cs Convert notification tests and exception assertions.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Android.App/​ApplicationTest.cs Convert application test attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniValueMarshalerAttributeTests.cs Convert marshaler tests and exact exception checks.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniUtf8RemappingTests.cs Convert remapping data rows and string assertions.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniTypeSignatureTest.cs Convert signature tests and exception assertions.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniTypeSignatureAttributeTest.cs Convert signature-attribute tests and exception checks.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniTypeManagerTests.cs Convert type-manager tests; rename the GetType test.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniRuntimeTest.cs Convert runtime tests and identity assertions.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniReferenceLeakMeasurement.cs Inject logging and convert leak-growth assertions.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniPeerMembersTests.cs Convert peer-member tests and categories.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniNativeRegistrationTests.cs Convert registration cases and exact exception checks.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniMarshalTests.cs Convert marshaling test attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JniEnvironmentTests.cs Convert environment tests, exceptions, and skips.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaSingleArrayContractTests.cs Convert float-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaSByteArrayContractTests.cs Convert signed-byte-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaPrimitiveArrayContract.cs Convert shared primitive-array assertions.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaPeerableExtensionsTests.cs Convert peer-extension tests and exception checks.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaObjectTest.cs Convert object tests and reference-value comparisons.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaObjectExtensionsTests.cs Convert object-extension tests and exception checks.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaObjectArrayTest.cs Convert array fixtures and test-context lifecycle logging.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaInt64ArrayContractTests.cs Convert 64-bit integer-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaInt32ArrayContractTests.cs Convert 32-bit integer-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaInt16ArrayContractTests.cs Convert 16-bit integer-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaExceptionTests.cs Convert Java exception test attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaDoubleArrayContractTests.cs Convert double-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaCharArrayContractTests.cs Convert character-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaBooleanArrayContractTests.cs Convert Boolean-array fixture attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​JavaArrayContract.cs Convert inherited class initialization and cleanup.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop/​AssemblyInfoTests.cs Convert assembly-information test attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Java.Interop-Tests.NET.csproj Replace NUnit with shared MSTest configuration.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Cadenza/​BaseRocksFixture.cs Adopt MSTest and restrict helper visibility.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Cadenza.Collections/​ListContract.cs Convert list-contract tests and equality checks.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Cadenza.Collections/​EnumerableContract.cs Convert enumerable-contract test attributes.
tests/​Mono.Android-Tests/​Java.Interop-Tests/​Cadenza.Collections/​CollectionContract.cs Convert collection-contract tests and exception checks.
tests/​CodeGen-Binding/​Xamarin.Android.JcwGen-Tests/​Xamarin.Android.JcwGen-Tests.csproj Adopt MSTest runner; retain the application root.
tests/​CodeGen-Binding/​Xamarin.Android.JcwGen-Tests/​TestInstrumentation.cs Switch JCW instrumentation to MSTest.
tests/​CodeGen-Binding/​Xamarin.Android.JcwGen-Tests/​KotlinUnsignedTypesTests.cs Convert Kotlin tests and array assertions.
tests/​CodeGen-Binding/​Xamarin.Android.JcwGen-Tests/​ExceptionTests.cs Convert cross-language exception test attributes.
tests/​CodeGen-Binding/​Xamarin.Android.JcwGen-Tests/​DimBindingTests.cs Convert interface-method tests and exception checks.
tests/​CodeGen-Binding/​Xamarin.Android.JcwGen-Tests/​ArrayMutationTests.cs Convert array-mutation tests and collection assertions.
eng/​Versions.props Centralize the TRX reporting package version.
eng/​Version.Details.xml Track TRX reporting through dependency updates.
Documentation/​workflow/​UnitTests.md Document MSTest execution, filtering, and trimming.
build-tools/​automation/​azure-pipelines-public.yaml Add opt-in SourceWriter execution and TRX publication.
.github/​skills/​tests/​SKILL.md Update the runtime test-framework description.
.github/​skills/​tests/​references/​test-catalog.md Document migrated suites, commands, and validation guidance.

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Needs Changes

Findings: 0 errors, 1 warning, 0 suggestions.

The new opt-in host stage unintentionally becomes a prerequisite of mac_build. The inline comment explains how this suppresses the macOS SDK build and dependent stages when the host suite fails or when both runNativeMtpHostTests and skipTests are enabled.

The fixture migration and runner wiring otherwise look well considered: explicit assembly registration, nonparallel execution, retained JNI/reflection roots, and distinct handling of test failures versus infrastructure failures. Full-source review of the changed test fixtures found no additional confirmed semantic regressions.

Validation limits: The latest Azure build 1679890 was still running when checked; CI is not yet confirmed green. Azure build/timeline queries required unavailable authentication. The local SourceWriter test command failed during .NET CLI first-use initialization with DirectoryNotFoundException, before build or test execution.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Android PR Reviewer for #13434 · copilot · gpt61 · 241.9 AIC · ⌖ 4.35 AIC · ⊞ 20.2K
Comment /review to run again

@jonathanpeppers

Copy link
Copy Markdown
Member

The test run looks good. 👍

I compared Azure DevOps build 1679890 (this PR) with the NUnit baseline build 1679118. No tests were lost:

Suite (runtime) Baseline This PR
Mono.Android.NET-Tests (CoreCLR) 1063 1063
Mono.Android.NET-Tests (NativeAOT) 1000 1000
Mono.Android.NET-Tests (JniReferenceLeak) 8 8
Xamarin.Android.JcwGen-Tests (CoreCLR) 47 47
Xamarin.Android.JcwGen-Tests (JniReferenceLeak) 1 1

Test titles and multiplicities match after name normalization, except for the GetType → GetTypeFromSignature rename. The skipped tests are also the same. The 63 fewer NativeAOT cases are the existing NativeAOTIgnore/SSL exclusions.

I updated the description: the table rows now use the suite names (the "Mono" label meant the Mono.Android suite, not the MonoVM runtime). I also added the CI results and the JNI lane count (8, not 6).

jonathanpeppers and others added 2 commits November 16, 2026 14:12
Resolve the JavaListTest.cs conflict with #13508 by converting its new
RemoveAll tests from NUnit to MSTest: [Test] -> [TestMethod],
[TestCase] -> [TestMethod] + [DataRow], [NonParallelizable] ->
[DoNotParallelize], and Assert.Throws<T> -> Assert.ThrowsExactly<T>.
BulkRemovalJavaList is kept next to the concrete MSTest classes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve the TrimmableTypeMapTypeManagerTests.cs conflict with #13526 by
converting its new NUnit attributes to MSTest: [Test] -> [TestMethod]
and [Category] -> [TestCategory].

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers

Copy link
Copy Markdown
Member

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 81ed63db against main at 185f6b4c (merge-base 0cb62f7d). This is a static, read-only review; I did not build or run tests.

  1. The merged runtime test project no longer compiles. Since this branch forked, main added JavaAnnotation_LongValueOutsideIntRange_UsesJavaLongLiteral in tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapRuntimeCoverageTests.cs. A three-way merge keeps that test's NUnit [Test] and AssertionException, but this PR removes NUnit and switches the file to MSTest. The merge is textually clean yet leaves unresolved types in Mono.Android.NET-Tests. Please bring in the target changes and convert the new test to [TestMethod] and AssertFailedException.

  2. The opt-in test stage gates the macOS build. As noted in the existing pipeline review thread, build-tools/automation/azure-pipelines-public.yaml places native_mtp_host_tests immediately before mac_build, which has no explicit dependsOn. When runNativeMtpHostTests=true, Azure makes mac_build depend on that stage: a host-test failure, or skipTests=true, skips the macOS build and its downstream stages. Please give mac_build dependsOn: [] or move the opt-in stage so build-only runs still build macOS.

Convert the JavaAnnotation_LongValueOutsideIntRange_UsesJavaLongLiteral
test that #13559 added to TrimmableTypeMapRuntimeCoverageTests.cs to
MSTest: [Test] -> [TestMethod] and AssertionException ->
AssertFailedException. The merge was textually clean but did not compile.

Give mac_build `dependsOn: []`. Without it, mac_build implicitly depends
on the opt-in native_mtp_host_tests stage, so a host-test failure or
skipTests=true skipped the macOS build when runNativeMtpHostTests=true.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival and others added 2 commits November 17, 2026 10:47
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto thanks for the review. Both points are fixed as of d438a4a (merge of main at b0843532):

  1. JavaAnnotation_LongValueOutsideIntRange_UsesJavaLongLiteral in TrimmableTypeMapRuntimeCoverageTests.cs is converted to [TestMethod] and AssertFailedException. I checked the other test lines merged from main since then and found no remaining NUnit APIs. The only [Test]/[TestFixture] left in the migrated suites are TimingTests.cs and JniNativeInterfaceTests.cs, and both were already excluded with <Compile Remove> before this PR. All 30 checks passed on d438a4a in build 1684441, including Mac Build and Package Tests APKs 1 and 2, which build and run Mono.Android.NET-Tests.
  2. mac_build now has dependsOn: [], so the opt-in native_mtp_host_tests stage no longer gates the macOS build, even with skipTests=true. That thread is resolved.

Since then, head 3160d76 contains only docs changes: the test catalog no longer lists fixed expected case counts, and the PR description now names the commit each count was measured on. Could you take another look?

@dalexsoto

Copy link
Copy Markdown
Member

In response to @simonrozsival's request: I cannot complete this review in this iteration: 137 changed files still lack full source inspection, and the material integration paths and separate final completeness pass remain unverified. No formal review is being submitted on this incomplete coverage.

Xamarin.SourceWriter-Tests isn't run by any CI lane on main, and the opt-in host stage defaulted to off, so neither is needed to migrate the Android runtime suites. Restore the SourceWriter tests, project and pipeline to main.

Trim the test catalog and UnitTests.md additions to what the migration changes (runner, category selection, trimming roots), and drop a stale reference to the removed UID slicer. Fix a duplicated comment left by a merge in JavaConvertTest.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival changed the title [tests] Migrate Android runtime and SourceWriter tests to MSTest/MTP [tests] Migrate Android runtime tests to MSTest/MTP Nov 17, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed c60dfc63 against main at d008d388 (merge-base b0843532, 137 files). This is a static, read-only review; I did not build or run tests. This completes the review I deferred earlier.

Both points from my previous review are addressed: the first is fixed, and the second no longer applies because the opt-in pipeline stage was removed. I also verified the integration paths I had left open:

  • Test registration: all three migrated projects (Mono.Android.NET-Tests, Java.Interop-Tests.NET, JcwGen-Tests) import MSTest.Android.props, and MSTestInstrumentation registers their assemblies explicitly via AddMSTest. That includes Java.Interop-Tests through its alias. The removed TrimmerRootAssembly entries are replaced by the generated registry plus TrimmerRoots.xml.
  • Threading: neither the old NUnitLite runner nor the new MTP runner used the main Looper. The thread-sensitive tests (ApplicationTest, HandlerTest) don't depend on the instrumentation thread, and DoNotParallelize keeps execution serial.
  • Imports: every changed import and property reference resolves at this head (Configuration.props, Jar.targets, InstrumentationProtocol.cs, the version properties in eng/Versions.props).
  • CI: the existing stage-package-tests.yaml lanes still build and run all migrated projects through apk-instrumentation.yaml with --report-trx. The keys the runner emits (event/outcome/resultsPath, -1 on success) match what AndroidTestAdapter expects.

I found no blocking issues. LGTM.

@jonathanpeppers

Copy link
Copy Markdown
Member

🤖 CI triage: the only failure is a known flake. It is not related to this PR.

Build: #1685258

  • 1 job failed: MSBuild Emulator Tests › macOS › MSBuild+Emulator 11. All other checks passed.
  • 1 test failed: InstallAndRunTests.GradleFBProj((True, NativeAOT)). The test project failed to build (FailedBuildException). The other test in that lane passed.
  • This test is a known flake caused by Gradle/Maven dependency resolution (AGP plugin resolution, corrupt Gradle ZIP). It is tracked in CI flakiness inventory: Nov 4-9, 2026 (follow-up to #13278) #13429, which has an earlier recurrence on the same (True, NativeAOT) configuration.
  • This PR changes only test projects, docs, and the MSTest/TrxReport package versions. It does not touch the SDK, build tasks, or Gradle handling.

Confidence: about 0.8 (the test's build.log was not downloaded to confirm the exact Gradle error).

Suggested action: Retry failed jobs on the MSBuild Emulator Tests stage.

@jonathanpeppers
jonathanpeppers merged commit bfda00d into main Nov 17, 2026
36 of 38 checks passed
@jonathanpeppers
jonathanpeppers deleted the simonrozsival-mstest-delivery-host-ci branch November 17, 2026 14:35
simonrozsival added a commit that referenced this pull request Nov 17, 2026
Context: #13434

#13434 moved the on-device suites and Xamarin.SourceWriter-Tests to
MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 17, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 18, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 21, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 26, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 27, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 27, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 28, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit that referenced this pull request Nov 29, 2026
Context: #13434

MSTest on Microsoft.Testing.Platform (MTP).  Every other test project
was still NUnit, so the repo carried two frameworks, two runners,
TestRunner.Core, the NUnit console scripts, and dotnet-test-slicer.

Migrate all remaining NUnit test projects to MSTest/MTP:

  * Java tooling: generator-Tests,
    Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests,
    Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests
  * Android tooling: Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests,
    Microsoft.Android.Build.BaseTasks-Tests,
    Microsoft.Android.Sdk.Analysis.Tests
  * Build tasks: Microsoft.Android.Build.Tasks.Tests,
    Xamarin.Android.Build.Tests, Xamarin.ProjectTools
  * Device integration: MSBuildDeviceIntegration

`build-tools/scripts/NUnitReferences.projitems` is replaced by
`MSTestReferences.projitems`; versions come from `eng/Versions.props`.
The root `global.json` selects the MTP runner.

CI: `run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are
replaced by `run-mstest-tests.yaml`, which runs the test app directly
with `--report-trx`.  Slicing uses `--list-tests` and `--filter-uid`
with the same count-based round-robin split as dotnet-test-slicer,
retries use `Microsoft.Testing.Extensions.Retry`, and NUnit filters
are translated to MSTest filter syntax.

StreamingTests now run the built Microsoft.Android.Run out of process
under `dotnet test --test-modules`: with MTP 2.6, an in-process
`TestApplication` using `--report-trx` relaunches the MSTest test app
itself and recurses.

LocalizationTests now restore `persist.sys.locale` to `en-US`.

Remove the now unused TestRunner.Core, nunit3-console scripts, NUnit
version properties, dead NUnit test sources and stale references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
jonathanpeppers pushed a commit that referenced this pull request Nov 30, 2026
Context: #13434

#13434 (merged) moved the on-device suites (`Mono.Android.NET-Tests`, `Java.Interop-Tests`, `Xamarin.Android.JcwGen-Tests`) and `Xamarin.SourceWriter-Tests` to MSTest on Microsoft.Testing.Platform (MTP). Every other test project was still NUnit, so the repo had to carry two runners, `TestRunner.Core`, the NUnit console scripts, `build-tools/automation/scripts/RunSlicedTests.cs`, and per-project `global.json` files to select MTP.

This PR migrates all remaining NUnit test projects, which means one framework and one runner for the whole repository.

### Projects

  * Java tooling: `generator-Tests`, `Java.Interop.Tools.{Generator,JavaCallableWrappers,JavaSource,JavaTypeSystem,Maven}-Tests`, `Xamarin.Android.Tools.{Bytecode,ApiXmlAdjuster}-Tests`
  * Android tooling: `Xamarin.Android.Tools.{Aidl,AndroidSdk}-Tests`, `Microsoft.Android.Build.BaseTasks-Tests`, `Microsoft.Android.Sdk.Analysis.Tests`
  * Build tasks: `Microsoft.Android.Build.Tasks.Tests`, `Xamarin.Android.Build.Tests` and its shared `Xamarin.ProjectTools` library
  * Device integration: `MSBuildDeviceIntegration`, `TrimmingTests` (added on main by #13657; runs two tests at a time with `[assembly: Parallelize (Workers = 2)]`, and its once-per-class device check is a `[ClassInitialize]`)

`build-tools/scripts/NUnitReferences.projitems` is replaced by `MSTestReferences.projitems`. It makes each project an MTP executable (`EnableMSTestRunner`) and references `MSTest.*` and `Microsoft.Testing.Extensions.TrxReport` with versions from `eng/Versions.props`.

`MSTest.SourceGeneration` is used everywhere except `Xamarin.Android.Build.Tests`, `MSBuildDeviceIntegration` and `TrimmingTests`. Those see `Xamarin.Android.Build.Tasks`' internal `DynamicallyAccessedMemberTypes` polyfill through `InternalsVisibleTo`, which conflicts with the generated code (CS0433), so they use reflection discovery (`UseMSTestSourceGeneration=false`).

The root `global.json` now selects MTP (`"test": { "runner": "Microsoft.Testing.Platform" }`). The `DOTNET_TEST_RUNNER` environment variable is removed. The per-project `global.json` files for the on-device suites (`Mono.Android.NET-Tests`, `Xamarin.Android.JcwGen-Tests`) are kept: without them, the `_MTPBuild` MSBuild process that `dotnet test` spawns in `apk-instrumentation.yaml` resolved the 11.0.100-rc.1 Android workload manifest and failed with NETSDK1139.

Removed: `tests/TestRunner.Core`, `build-tools/scripts/nunit3-console*`, the `NUnitVersion`/`NUnitConsoleVersion` properties, and the dead `run-nunit-tests`/`list-nunit-tests` make targets (`RunTests.targets` no longer exists).

### Conversion notes

  * `[TestCase]`/`[TestCaseSource]` → `[DataRow]`/`[DynamicData]`. `TestCaseData.SetName()` → `TestDataRow<T>.DisplayName`. `[Values]` → `[CombinatorialData]`/`[CombinatorialValues]`. `[ValueSource (…ValidRuntimeConfigurations)]` → a small `[ValidRuntimeConfigurations]` values provider.
  * NUnit `[SetCulture ("x")]` → a `[DataRow ("x")]` (or an inline switch for a single culture) that sets `CultureInfo.CurrentCulture` and restores it in `finally`.
  * `[Category]` → `[TestCategory]`, `[Platform]` → `[OSCondition]`, `[Explicit]` → `[Ignore]`. NUnit `[Retry (n)]` (n total attempts) → MSTest `[Retry (n - 1)]` (n - 1 retries).
  * Parallelism matches NUnit. `Xamarin.Android.Build.Tests` and `Microsoft.Android.Build.Tasks.Tests` run method-level parallel. Classes that were not `[Parallelizable (Children/All)]` are `[DoNotParallelize]`. `MSBuildDeviceIntegration` stays assembly-wide `[DoNotParallelize]`.
  * `BaseTest` uses the MSTest `TestContext`. `TestName` comes from `TestDisplayName`, so every data row still gets its own directory. Outcome checks use `CurrentTestOutcome`, and attachments use `AddResultFile()`. `[OneTimeSetUp]`/`[OneTimeTearDown]` → `[ClassInitialize]`/`[ClassCleanup]` with `InheritanceBehavior.BeforeEachDerivedClass`.
  * NUnit fixture parameters have no MSTest equivalent:
    * `TimeZoneInfoTests` and `LocalizationTests` become abstract bases with `…CoreCLRTests`/`…NativeAOTTests` subclasses. Each subclass installs its app lazily, once per runtime.
    * `BundleToolTests` and `BundleToolNoAbiSplitTests` take the runtime as a `[DataRow]`.

### Remove redundant Maven runtime variants

Keep all four `BindingBuildTest.AndroidMavenLibrary*` methods and their distinct assertions, but remove their four NativeAOT-labelled variants. These tests build binding libraries and exercise Maven download and dependency verification, not execution of an AOT application; the extra runtime-labelled builds repeat that path and increase the number of builds sharing the Maven cache. The base `AndroidMavenLibrary` case now uses CoreCLR Release, while the three dependency-verification cases use CoreCLR Debug. This drops the NativeAOT-labelled configurations and Release coverage for those three verification cases; it does not remove any of the four test methods or `MavenDownloadTests` cases.

The Maven cases remain serialized to avoid a reproduced cold-cache file-sharing race during test execution. Serialization does not fix that underlying shared-cache race for concurrent customer builds.

### CI

`run-nunit-tests.yaml` and `run-sliced-nunit-tests.yaml` are replaced by `run-mstest-tests.yaml`. It runs the test app directly (`dotnet <dll> --report-trx`) and publishes its TRX. A failing run marks the step *SucceededWithIssues*, and `fail-on-issue.yaml` then fails the job, the same as before.

  * Slicing: `--list-tests json` lists the selected tests. The job takes every `$(System.TotalJobsInPhase)`th test, sorted by UID, and passes those UIDs in a `--filter-uid` response file. This replaces `build-tools/automation/scripts/RunSlicedTests.cs` (#13563, which itself replaced `dotnet-test-slicer`); the script built an NUnit `<Where>` filter, so it is deleted. It is the same count-based round-robin split (`index % totalSlices`) that the script and `dotnet-test-slicer` did: our pipelines never passed the slicer a `--balance-file`, so every test was weighed equally, and neither approach balances by test duration, so slice sizes are unchanged.
  * Retry: `MSBuildDeviceIntegration` references `Microsoft.Testing.Extensions.Retry`, new in `eng/Versions.props` and `eng/Version.Details.xml`. The lanes that used `RunSlicedTests.cs --retry` now pass `--retry-failed-tests 1` and publish every attempt from `Retries/`.
  * Filters:
    * `Name = BuildTest` → `ClassName=Xamarin.Android.Build.Tests.BuildTest` (also for `PackagingTest`, `XASdkTests`, `AndroidDependenciesTests` and `SystemApplicationTests`).
    * `method == X` → `Name~X`.
    * `cat != A & …` → `TestCategory!=A&…` (`ExcludedNightlyNUnitCategories` is renamed to `ExcludedNightlyTestCategories`).
  * The Android tools stage uses `dotnet test --project … --report-trx`, because `DotNetCoreCLI@2` injects `--logger trx`, which MTP rejects. The `run-dotnet-preview.yaml` callers switch to `--report-trx`.

### Results

Rebased onto main (8ac0d3a). The tests #13749 and #13776 added with NUnit are converted (`GenerateTrimmableTypeMapTests.AliasResolutionPrefersNonGenericBinding`, `InstallAndRunTests.TrimmableTypeMapGenericBindingAliases`, `JavaPeerActivationTests.UntypedJavaActivationPrefersNonGenericBindingWithoutWarnings` and the new `DefaultInterfaceMethodsTests` nullability tests). Earlier rebases converted main's NUnit tests added since the migration started are converted: `TrimmingTests` (including the fixtures #13658 added, where `[NonParallelizable]` becomes `[DoNotParallelize]` and `Assert.Ignore` becomes `Assert.Inconclusive`), `TrimmableTypeMapValueTypeTests`, `KotlinDefaultArgumentsTests`, `GenerateCoreClrRuntimeProviderSourcesTests`, and new methods in `AndroidDependenciesTests`, `AssetPackTests`, `BindingBuildTest`, `BuildWithLibraryTests`, `BundleToolTaskTests`, `CodeBehindTests`, `CodeGeneratorTests`, `FieldWriterTests`, `ManagedTests`, `KotlinInlineClass*Tests`, `PackagingTest`, `TrimmableTypeMapBuildTests`, `BuildTest2`, `NativeAotBuildTests`, `RemoveDirTests`, `EmulatorRunnerTests` (NUnit `Assert.CatchAsync` → `Assert.ThrowsAsync`, which also accepts derived exceptions), `NativeLibraryLoadTests` (NUnit `TestContext.Out`/`AddTestAttachment` → `Console.Out`/`AddResultFile`), plus the `[SetCulture]` tests from #13794 and #13810. The `TrimmingTests` CI matrix keeps main's per-configuration filters, passed to `run-mstest-tests.yaml`. Validation after the latest rebase, with `make prepare && make leeroy CONFIGURATION=Release`:

  * All 17 projects that import `MSTestReferences.projitems` rebuild (`-t:Rebuild -p:BuildProjectReferences=false -p:_AndroidTreatWarningsAsErrors=true`): 0 warnings, 0 errors. An earlier incremental build had missed AOTSG0005 in `generator-Tests`, which failed CI build 1701517.
  * After the 4347e8c rebase: `EmulatorRunnerTests` 27/0/0; `Xamarin.Android.Build.Tests` `RemoveDirTests`, `AndroidCreateDebugKeyTests` and main's new `BasicApplicationReadyToRunCustomConfiguration` (8 rows), `BuildPackageFormatsUnoptimizedCustomConfiguration`, `PublishNativeAotAppBundleIncludesDebugSymbolsCustomConfiguration`: 20/0/3 (the 3 are Windows-only `Assert.Inconclusive`).
  * From the 7ad6d6f rebase: `generator-Tests` 502/0/0, `Xamarin.Android.Tools.Aidl-Tests` 18/0/0, `Java.Interop.Tools.Maven-Tests` 107/0/0, `Microsoft.Android.Build.Tasks.Tests` 1110/0/8; `Xamarin.Android.Build.Tests` touched tests 22/0/0.
  * `TrimmingTests` discovers 107 tests. The CI matrix filters (`Name~CoreClrFullTrimming`, `Name~NativeAot`, `Name!~CoreClrFullTrimming&Name!~NativeAot`) select 35, 36 and 36 of them, covering each test exactly once. The new fixtures were not run on a device after this rebase.
  * From the 0df9e25 rebase: `Xamarin.Android.Build.Tests` converted/conflicted tests 29/0/0; `Bytecode-Tests` 139/0/2; `SourceWriter-Tests` 12/0/0.
  * From the previous rebase (6394e85): `Xamarin.Android.Build.Tests` converted/conflicted tests 101/0/0; on an API 35 arm64 emulator, `TrimmingTests` 22/0/3 (the 3 are the `[Ignore]`d #13635 case). `MSBuildDeviceIntegration` `IncrementalFastDeployment` (apk, aab) and `GradleLibrary` passed; `StackTraceContainsLineNumbers` and `AppBundleDeploymentInvalidation` failed on both attempts, the first with the same message as on the pre-migration NUnit code and the second on an untargeted `adb uninstall` with other sessions' emulators attached.

Before that rebase, all 17 migrated projects built with `-p:_AndroidTreatWarningsAsErrors=true`.

Standalone suites, MTP run on this branch (passed/failed/skipped):

| Suite | MSTest/MTP |
|---|---|
| Xamarin.Android.Tools.Aidl-Tests | 17/0/0 |
| Microsoft.Android.Build.BaseTasks-Tests | 166/0/4 |
| Xamarin.Android.Tools.AndroidSdk-Tests | 444/4/11 |
| Microsoft.Android.Sdk.Analysis.Tests | 14/0/1 |
| Java.Interop.Tools.Generator-Tests | 18/0/0 |
| Java.Interop.Tools.JavaCallableWrappers-Tests | 21/0/0 |
| Java.Interop.Tools.JavaSource-Tests | 41/0/0 |
| Java.Interop.Tools.JavaTypeSystem-Tests | 17/0/0 |
| Java.Interop.Tools.Maven-Tests | 106/0/0 |
| Xamarin.Android.Tools.ApiXmlAdjuster-Tests | 13/0/0 |
| Xamarin.Android.Tools.Bytecode-Tests | 132/0/2 |
| generator-Tests | 478/0/0 |
| Microsoft.Android.Build.Tasks.Tests | 1071/0/16 |

The four `AndroidSdk-Tests` failures are local build or environment differences, not regressions. The 3 `CreateProcessStartInfo_*` tests pass when the project is built the way CI builds it (`-p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=11.0`). `Constructor_SetValuesFromPath` fails because the product probes `~/android-toolchain` for a JDK, and it fails the same way under NUnit.

Comparison with main's NUnit suites:

  * Main's NUnit `BaseTasks-Tests` and `AndroidSdk-Tests` were run in a clean worktree. Totals are 170 and 459 (NUnit `--list-tests`), the same as MTP, with identical per-method case counts.
  * For every test source file, the NUnit test-case count on main was compared with the MSTest count on this branch. Before the later Maven matrix reduction, they matched except for the intentional expansions listed below: fixture parameters and `[Values]` that become rows (`AndroidUpdateResourcesTest` +3, `TrimmableTypeMapBuildTests` +1, `ExtractTypeMapKeysFromNativeAotObjectCoverageTests` +2, `BundleTool*Tests` +1 each, `DebuggingTest` +1). The Maven change subsequently removes four runtime-labelled rows as described above.
  * Earlier MTP discovery: `Xamarin.Android.Build.Tests` 1853, `MSBuildDeviceIntegration` 4533. The later Maven-focused validation discovered 1835 build tests after removing the four variants, versus 1839 immediately before that reduction.

Device runs before the rebase, with a local Release SDK on an API 35 arm64 emulator:

| Check | MSTest/MTP |
|---|---|
| `Xamarin.Android.Build.Tests` `TestCategory=SmokeTests` | 35/0/2 (the 2 are Windows-only `Assert.Inconclusive`) |
| `UncaughtExceptionTests`, `BundleToolTests`, `WebViewJavascriptInterfaceTests` (with `--retry-failed-tests 1`) | 8/0/0 |
| `LocalizationCoreCLRTests.CheckLocalizationIsCorrectNode15` (then `persist.sys.locale` is back to `en-US`) | 30/1/0 (`ar-KM`: the app didn't start within the logcat window after the reboot, all 3 attempts) |
| 2× TimeZone CoreCLR, 2× TimeZone NativeAOT, 2× Localization CoreCLR, 4× `InstallTests` (UID slice) | 10/0/0 |

Discovery differs from NUnit in naming and in the intentional case changes noted above. Rows that NUnit named with `TestName =`/`SetName()` now appear under their method name with a `DisplayName`, and fixture-parameterized classes appear under their new subclass names.

The `run-mstest-tests.yaml` script was exercised locally with `pwsh`: slicing `Xamarin.Android.Build.Tests` 3 ways (8/8/8 of 24), plus a 4-way dry run over the 1182 TimeZone tests. All pipeline YAML parses.

After the Maven matrix reduction, validation used the local Release SDK and a warm shared Maven cache (`JAVA_HOME=~/android-toolchain/jdk-21`, `ANDROID_SDK_ROOT` unset):

  * `./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -c Release -p:_AndroidTreatWarningsAsErrors=true` — passed, 0 errors.
  * `./dotnet-local.sh bin/TestRelease/net11.0/Xamarin.Android.Build.Tests.dll --list-tests --filter "Name~AndroidMavenLibrary"` — discovered the four unparameterized methods.
  * `./dotnet-local.sh bin/TestRelease/net11.0/Xamarin.Android.Build.Tests.dll --filter "Name~AndroidMavenLibrary" --report-trx --results-directory /tmp/maven-validate --progress off` — 4 passed, 0 failed, 0 skipped. The warm-cache run does not exercise the cold-cache race.

Full suites, run locally at 785a30f on one macOS arm64 host, both at the same time, unsliced in one process each (CI splits them across agents):

| Suite | Command | Wall time | Passed/failed/skipped |
|---|---|---|---|
| `Xamarin.Android.Build.Tests` | `./dotnet-local.sh bin/TestRelease/net11.0/Xamarin.Android.Build.Tests.dll --report-trx` | 2h 39m | 1747/18/70 |
| `MSBuildDeviceIntegration`, first attempt | `ADB_TARGET='-s emulator-5590' ./dotnet-local.sh bin/TestRelease/MSBuildDeviceIntegration/net11.0/MSBuildDeviceIntegration.dll --filter "TestCategory!=SystemApplication&TestCategory!=TimeZoneInfo&TestCategory!=Localization" --retry-failed-tests 1 --report-trx` (API 35 arm64 emulator) | 3h 19m | 175/47/33 |

None of the failures come from the migration. Each failure was rerun on its own; the ones that still failed also fail on the pre-migration NUnit code (cc7cbf6) under the same conditions.

`Xamarin.Android.Build.Tests`:

  * `BuildBasicApplicationCheckPdbRepeatBuild`, `BuildAppCheckDebugSymbols`, 4× `DotNetBuildLibrary`, `BuildWithNativeLibraries`, `AppProjectTargetsDoNotBreak`: an emulator was attached, so the build narrowed `RuntimeIdentifiers` to `android-arm64` and the expected x86_64 outputs were missing. NUnit fails the same 8 with a device attached. With no visible device (a private adb server), they pass: 12/0/6.
  * 4× `BuildReleaseArm64`: `apkdiff` wasn't installed. They pass with apkdiff 0.0.17, the version CI installs.
  * `BootUsesTaskEnvironment`: expects `/var/...` but gets `/private/var/...` on macOS. It fails the same way under NUnit.
  * 3× `DotNetPublish` and 2× `MauiTargetFramework` for 37.2: the local SDK build only puts `Microsoft.Android.Sdk.Analysis.dll` in the latest stable Ref pack (CS0006). With it copied into the 37.1/37.2 packs, 3 pass. The other 2 `DotNetPublish` rows fail in javac because the local `android-37.2` platform jar lacks `android.app.personalcontext`.

`MSBuildDeviceIntegration`: two other emulators were on the same adb server, so `dotnet run`, bundletool, and `adb` calls without `-s` either refused to pick a device or used the wrong one. The emulator also ran out of `/data` space. The run was stopped during its retry pass. The 18 affected methods (63 rows) were rerun through a private adb server that sees only one emulator: 41/10/12, plus 1 pass on retry. Of the 9 rows that still fail:

  * `UnhandledExceptionFromButtonClick`, `NativeCrashProducesManagedStackTrace`, `StackTraceContainsLineNumbers`, `NativeAOTCustomReleaseConfiguration (False)`, and `AdbTargetArchitecture` fail with the same messages under NUnit on the same device (5/5).
  * `DotNetInstallAndRunPreviewAPILevels (False, 37.2)` hits the same local platform-jar javac error.
  * 3× `DotNetInstallAndRunMinorAPILevels` (`net11.0`) are inconclusive locally: the shipped 37.2.0-rc.2 tooling finds devices through the default adb port, which the private-server setup breaks.

### Review fixes (fb10471)

Each of the 18 migrated projects was reviewed separately against main's NUnit code. Fixes:

  * `[NoClassCleanup]`, the `DeviceTest` reference count, and the cached one-time setup failure described under Notable conversions.
  * `StreamingTests` regains the assertions the out-of-process conversion had dropped: `[unfinished]` tests, full partial counts, no "native crash" label, and the TRX-write failure message.
  * `TrimmableTypeMapValueTypeTests` and `SymbolicLinkTests` are `[DoNotParallelize]`, because NUnit ran them serially.

Follow-up review fixes (f639a40, bee6477):

  * `TrimmingTestBase` called the counted `DeviceSetup` again after `RestartDevice ()`, which leaked the class count and skipped re-querying the device. It now calls an uncounted `ResetupDevice ()` that refreshes the cached `adb` state first.
  * With `--retry-failed-tests`, the main run now publishes the first attempt without the failures it retried, and the final attempt is published as a separate "(Auto-Retry)" run, as `RunSlicedTests.cs` did. The results-directory TRX is treated as the final attempt, so this also works with newer Retry versions that delete the final attempt from `Retries/`. Checked locally with `pwsh` against a probe (one passing, one always-failing and one fail-then-pass test) in four scenarios: the current and the newer Retry layout, each with and without retries.
  * Removed the opt-in `native_mtp_host_tests` stage, which the migration doesn't need, and its README note.

Not changed:

  * `SourceJavadocToXmldocParserTests.TryParse` rows share a display name, as they did under NUnit.
  * The Maven matrix reduction is intentional (see above).

Validation, with `-t:Rebuild -p:_AndroidTreatWarningsAsErrors=true` (0 warnings, 0 errors):

  * `Xamarin.Android.Build.Tests`, `MSBuildDeviceIntegration`, `TrimmingTests` and `Microsoft.Android.Build.Tasks.Tests`: rebuild clean.
  * `CollectNonEmptyDirectoriesTests` and `SymbolicLinkTests`: 11/0/0.
  * `TrimmableTypeMapValueTypeTests`: 1/0/0.
  * `AndroidSdk-Tests`: 449/1/12, including `StreamingTests` 16/0/0. The cancellation and TRX rows passed 15 out of 15 repeated runs.
  * On an API 35 arm64 emulator:
    * `LocalizationCoreCLRTests.CheckLocalizationIsCorrectNode1`: 223/0/0. The app stayed installed after class cleanup.
    * `CallbackTests` and `BindingTrimmingTests` (`CoreClrPartialTrimming`) running in parallel: 9/0/2.

### Notable conversions

  * `AndroidSdk-Tests`' `StreamingTests` (added on main) built an in-process MTP `TestApplication` with `--report-trx`. Under the MTP 2.6 that MSTest brings in, `--report-trx` always makes the app a test-host controller, which relaunches the entry assembly (the MSTest test app itself) and recurses. They now run the built `Microsoft.Android.Run` under `dotnet test --test-modules`, which is how Android test projects run it, with a fake adb replaying an `am instrument` transcript. This also tests the MTP 2.2.1 that `Microsoft.Android.Run` ships with. Cancellation is driven by the fake adb sending SIGINT to `Microsoft.Android.Run`. The missing-adb case uses a non-executable adb, because `Microsoft.Android.Run` rejects a missing path before MTP starts. The two parser/state tests stay in process.
  * `LocalizationTests` restore `persist.sys.locale` to `en-US` in a `[ClassCleanup]`. The NUnit version never restored it, so later suites on the same device ran in the last tested locale.
  * Main's no-op `AfterAllTests`/`DeviceTearDown` overrides can't be overridden once those are static `[ClassCleanup]` methods. A `[NoClassCleanup]` attribute marks the classes that opted out: the host-only `AndroidComputeResPathsTests`, `CollectNonEmptyDirectoriesTests` and `ResolveSdksTaskTests` (no `adb kill-server` on Windows), and the `Localization`/`TimeZoneInfo` subclasses (the installed app is kept).
  * `DeviceTest` reference-counts its class setup and teardown. With method-level parallelism, `TrimmingTests` classes overlap, which NUnit's `ParallelScope.Children` never did, so only the last class to finish tears the device down.
  * `LocalizationTests`/`TimeZoneInfoTests` install their app in `[TestInitialize]`, the first time each runtime needs it. If that install fails, the failure is cached and the remaining rows fail immediately, as with NUnit's `[OneTimeSetUp]`, instead of rebuilding the app for every row.
  * `UncaughtExceptionTests`' `Assert.Multiple` (no MSTest equivalent) collects the property-restore failures and asserts once.

### Known issues

  * `AndroidUpdateResourcesTest.LightlyModifyLayout` drops NUnit's `[Repeat (3)]`; it runs once. `ZipArchiveExTests`' `[Repeat (100)]` becomes an explicit loop.
  * `[Explicit]` tests become `[Ignore]`. MSTest has no opt-in-only equivalent, so they no longer run when selected explicitly by name.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants