Skip to content

[ci] Replace dotnet-test-slicer with RunSlicedTests.cs - #13563

Merged
simonrozsival merged 9 commits into
mainfrom
jonathanpeppers-mtp-test-slicing
Nov 19, 2026
Merged

simonrozsival merged 9 commits into
mainfrom
jonathanpeppers-mtp-test-slicing

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

dotnet-test-slicer found 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 with dotnet 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.Tests and MSBuildDeviceIntegration set EnableNUnitRunner=true. NUnitReferences.projitems moves to NUnit3TestAdapter 6.3.1. dotnet test <dll> still works.

Test filters now use dotnet test syntax, for example TestCategory!=Localization.

Tested locally on Windows:

  • Each test is in exactly one job for all CI filters and job counts.
  • Retry: a test that fails once passes; a test that always fails still fails.
  • dotnet test passes for all projects that import NUnitReferences.projitems.

@jonathanpeppers jonathanpeppers changed the title [ci] Replace dotnet-test-slicer with Microsoft.Testing.Platform slicing [ci] Replace dotnet-test-slicer with RunSlicedTests.cs Nov 13, 2026
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review November 13, 2026 22:00
Copilot AI balanced review requested due to automatic review settings November 13, 2026 22:00

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

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);
Base automatically changed from jonathanpeppers-slow-test-analysis to main November 14, 2026 23:57
jonathanpeppers and others added 7 commits November 16, 2026 14:45
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]>
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 and others added 2 commits November 17, 2026 14:30
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
simonrozsival merged commit 857f463 into main Nov 19, 2026
38 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers-mtp-test-slicing branch November 19, 2026 07:58
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]>
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.

3 participants