Repository navigation
[ci] Replace dotnet-test-slicer with RunSlicedTests.cs - #13563
Merged
Merged
Conversation
jonathanpeppers
marked this pull request as ready for review
November 13, 2026 22:00
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Initial failed test results are deleted before retries complete, so a failed or incomplete retry can leave published reports without the original failures and stack traces.
1 open issue
What changed in this PR
Replaces dotnet-test-slicer with an in-repository runner using Microsoft.Testing.Platform, building on #13550 to prevent CI jobs from silently passing without running tests.
Changes:
- Adds test discovery, deterministic slicing, minimum test-count checks, and one retry for failed tests.
- Enables executable NUnit runners for host and device integration tests and updates shared test dependencies.
- Migrates CI templates and filters, removes slicer installation, and documents the new command.
| File | Description |
|---|---|
tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj |
Enables the executable NUnit runner for device integration tests. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj |
Enables the executable NUnit runner for build tests. |
build-tools/scripts/NUnitReferences.projitems |
Updates the NUnit adapter and adds TRX reporting support. |
build-tools/automation/yaml-templates/variables.yaml |
Removes the slicer version and converts category filters. |
build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml |
Uses the updated filter and removes slicer setup. |
build-tools/automation/yaml-templates/setup-test-environment.yaml |
Removes the slicer installation parameter. |
build-tools/automation/yaml-templates/setup-test-environment-steps.yaml |
Removes external slicer installation. |
build-tools/automation/yaml-templates/setup-test-environment-public.yaml |
Removes slicer setup forwarding. |
build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml |
Invokes the new runner and publishes initial and retry reports. |
build-tools/automation/yaml-templates/run-msbuild-tests.yaml |
Updates filter documentation and removes slicer setup. |
build-tools/automation/scripts/RunSlicedTests.cs |
Implements discovery, slicing, execution, and retry handling. |
build-tools/automation/azure-pipelines-public.yaml |
Migrates public CI configuration. |
build-tools/automation/azure-pipelines-nightly.yaml |
Converts nightly test filters and removes slicer setup. |
build-tools/automation/azure-pipelines-internal.yaml |
Migrates internal CI configuration. |
.github/skills/tests/SKILL.md |
Documents running a test slice locally. |
Review effort: Balanced
Comment on lines
+72
to
+74
| result.Remove (); | ||
| } | ||
| trx.Save (trxPath); |
Xamarin.Android.Build.Tests and MSBuildDeviceIntegration now use NUnit's Microsoft.Testing.Platform (MTP) runner. VSTest (dotnet test <dll>) still works. The new build-tools/automation/scripts/Run-SlicedTests.ps1: * Lists the tests with `--list-tests json` and the MTP `--filter`. * Gives each parallel job every Nth test, sorted by name. * Runs the selected tests with an NUnit <Where> filter, and uses `--minimum-expected-tests` so a job that runs fewer tests fails. * Runs failed tests again once, and writes a separate TRX file. Remove the dotnet-test-slicer tool install and version. Co-authored-by: Copilot App <[email protected]>
Replace Run-SlicedTests.ps1 with RunSlicedTests.cs, a C# file-based app that CI runs with the repo-local `dotnet run`. The behavior does not change. Co-authored-by: Copilot App <[email protected]>
* Find dotnet from the runtime directory instead of --dotnet. * Use plain --name value arguments. * Put the package versions in NUnitMTPReferences.projitems. * Shorter comments and docs. Co-authored-by: Copilot App <[email protected]>
Remove NUnitMTPReferences.projitems. Projects that set EnableNUnitRunner=true get NUnit3TestAdapter 6.3.1 and the MTP TRX report. Microsoft.NET.Test.Sdk 17.5.0 works with both runners. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Use NUnit3TestAdapter 6.3.1 and the MTP TRX report for every project, so the file does not need to check EnableNUnitRunner. Co-authored-by: Copilot App <[email protected]>
CI builds the file with warnings as errors (CS8714, CS8621). Co-authored-by: Copilot App <[email protected]>
jonathanpeppers
force-pushed
the
jonathanpeppers-mtp-test-slicing
branch
from
November 16, 2026 20:47
e83c44e to
edd736b
Compare
9 tasks
MTP does not count skipped tests, so jobs with ignored tests failed. Co-authored-by: Copilot App <[email protected]>
…est-slicing # Conflicts: # .github/skills/tests/SKILL.md
simonrozsival
approved these changes
Nov 18, 2026
This was referenced Nov 19, 2026
jonathanpeppers
pushed a commit
that referenced
this pull request
Nov 20, 2026
Context: #13563 Six Windows shards in scheduled build 1691566 failed discovery with `Unknown option '--workers'`. Losing the empty filter argument shifts the slicer option pairs and makes --workers the filter value. PowerShell Legacy argument passing reproduces the exact failure; the source of the argument loss on the affected agents remains unconfirmed. Only pass --filter to the slicer when TEST_FILTER is nonempty, and omit it from MTP discovery when no filter is requested. This avoids depending on empty native arguments at either process boundary. Validation: the rendered pipeline PowerShell step passed 16 cases against NUnit3TestAdapter 6.3.1 on macOS, covering unset/empty filters, category and name filters, spaces/operators, slicing, and no-match failures under both Standard and Legacy argument passing. An explicit empty filter also passed when invoking the slicer directly. YAML parsing and git diff --check pass. Windows agents and CodeQL were not reproduced locally. Co-authored-by: Copilot App <[email protected]>
simonrozsival
added a commit
that referenced
this pull request
Nov 21, 2026
The rebase onto cc7cbf6 kept the pre-rebase MSTest conversions of files that main had changed since aa688ac, which reverted those changes and broke the build. For each affected file, convert main's old and new NUnit versions with the same converter and merge the difference into the MSTest file: * cca255c (#13592): drop the Android lint tests and assertions. * 5b32fb1 (#13602): add RelativeDirectoriesUseProjectDirectory and the -mt CollectNonEmptyDirectories coverage. * 78ef747 (#13655): add OpenGenericProxiesKeepTheReflectionActivationConstructor. * 18b8940 (#13585): add the generator nullability/obsolete tests. * dcbd008 (#13580): add the AmbiguousFunctionMetadata_* tests. * 667e27a (#13621): add the sdkmanager package ID tests. * 5ecb8f7 (#13614): drop RunWithLoggingEnablesManagedTimingLogger. * 8287b17 (#13680), 4bfcc92 (#13681): restore the re-enabled tests and removed TODOs. * 5d81a0f (#13666): expect platform-tools 37.0.3. * 8442c75 (#13601): assert the pulled device TRX is deleted. Also drop the EnableNUnitRunner/OutputType lines that 857f463 (#13563) added to Xamarin.Android.Build.Tests and MSBuildDeviceIntegration; MSTestReferences.projitems sets both. Co-authored-by: Copilot App <[email protected]>
simonrozsival
added a commit
that referenced
this pull request
Nov 21, 2026
857f463 (#13563) replaced dotnet-test-slicer with RunSlicedTests.cs, which builds an NUnit <Where> filter. This PR slices tests in run-mstest-tests.yaml with `--list-tests json` and `--filter-uid`, so nothing uses the script anymore. Delete it and document the run-mstest-tests.yaml approach in the tests skill. Co-authored-by: Copilot App <[email protected]>
This was referenced Nov 21, 2026
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.

dotnet-test-slicerfound 0 tests on macOS without failing, so macOS MSBuild tests did not run for weeks.Replace it with
build-tools/automation/scripts/RunSlicedTests.cs, run withdotnet run. It lists the tests with--list-tests json, runs every Nth test, and runs failed tests again once. A job with 0 tests fails.This needs Microsoft.Testing.Platform, so
Xamarin.Android.Build.TestsandMSBuildDeviceIntegrationsetEnableNUnitRunner=true.NUnitReferences.projitemsmoves to NUnit3TestAdapter 6.3.1.dotnet test <dll>still works.Test filters now use
dotnet testsyntax, for exampleTestCategory!=Localization.Tested locally on Windows:
dotnet testpasses for all projects that importNUnitReferences.projitems.