Skip to content

[dotnet] [test] Migrate to MTP#17384

Merged
nvborisenko merged 10 commits intoSeleniumHQ:trunkfrom
nvborisenko:dotnet-test-mtp
Apr 24, 2026
Merged

[dotnet] [test] Migrate to MTP#17384
nvborisenko merged 10 commits intoSeleniumHQ:trunkfrom
nvborisenko:dotnet-test-mtp

Conversation

@nvborisenko
Copy link
Copy Markdown
Member

@nvborisenko nvborisenko commented Apr 24, 2026

Seems successfully migrated to new modern Microsoft.Testing.Platform

🔗 Related Issues

Contributes to #15536

💥 What does this PR do?

  • Upgraded NUnit
  • Moved from NUnitLite to MTP

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s): Copilot
    • What was generated:
    • I reviewed all AI output and can explain the change

🔄 Types of changes

  • Cleanup (formatting, renaming)

Copilot AI review requested due to automatic review settings April 24, 2026 17:44
@selenium-ci selenium-ci added C-dotnet .NET Bindings B-build Includes scripting, bazel and CI integrations B-support Issue or PR related to support classes labels Apr 24, 2026
@selenium-ci
Copy link
Copy Markdown
Member

Thank you, @nvborisenko for this code suggestion.

The support packages contain example code that many users find helpful, but they do not necessarily represent
the best practices for using Selenium, and the Selenium team is not currently merging changes to them.

After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium
to work, we will likely close the PR.

We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks.
If you have any questions, please contact us

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Migrate .NET tests to Microsoft Testing Platform (MTP)

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Migrate .NET test infrastructure from NUnit to Microsoft Testing Platform
• Update NUnit version from 3.13.2 to 4.5.1 with NUnit3TestAdapter 6.2.0
• Replace custom NUnit shim with hand-ported MTP entry point implementation
• Update test argument format from --params to --test-parameter and --where to --filter
• Add MTP dependencies and remove legacy NUnitLite dependency

Grey Divider

File Changes

1. dotnet/private/mtp_shim.cs ✨ Enhancement +22/-0

Hand-ported MTP entry point and extension registration

dotnet/private/mtp_shim.cs


2. dotnet/defs.bzl ⚙️ Configuration changes +0/-2

Remove nunit_test rule export from public API

dotnet/defs.bzl


3. dotnet/paket.nuget.bzl Dependencies +13/-2

Add MTP and related NuGet package dependencies

dotnet/paket.nuget.bzl


View more (11)
4. dotnet/private/dotnet_nunit_test_suite.bzl ⚙️ Configuration changes +58/-27

Update test arguments and dependencies for MTP migration

dotnet/private/dotnet_nunit_test_suite.bzl


5. dotnet/private/nunit_test.bzl Miscellaneous +0/-12

Remove deprecated nunit_test rule implementation

dotnet/private/nunit_test.bzl


6. MODULE.bazel ⚙️ Configuration changes +1/-1

Export NUnit3TestAdapter NuGet package repository

MODULE.bazel


7. dotnet/paket.dependencies Dependencies +4/-2

Update NUnit and add MTP package versions

dotnet/paket.dependencies


8. dotnet/private/BUILD.bazel ⚙️ Configuration changes +28/-0

Export MTP shim and create NUnit3TestAdapter wrapper

dotnet/private/BUILD.bazel


9. dotnet/test/remote/BUILD.bazel ⚙️ Configuration changes +0/-1

Remove explicit NUnit dependency from test suite

dotnet/test/remote/BUILD.bazel


10. dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj ⚙️ Configuration changes +7/-3

Enable MTP and update NUnit/adapter versions

dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj


11. dotnet/test/support/BUILD.bazel ⚙️ Configuration changes +0/-1

Remove explicit NUnit dependency from test suite

dotnet/test/support/BUILD.bazel


12. dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj ⚙️ Configuration changes +7/-3

Enable MTP and update NUnit/adapter versions

dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj


13. dotnet/test/webdriver/BUILD.bazel ⚙️ Configuration changes +0/-1

Remove explicit NUnit dependency from test suite

dotnet/test/webdriver/BUILD.bazel


14. dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj ⚙️ Configuration changes +7/-6

Enable MTP and update NUnit/adapter versions

dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Apr 24, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Action required

1. nunit_test removed without deprecation 📘 Rule violation ⚙ Maintainability
Description
nunit_test is no longer exported from dotnet/defs.bzl, removing previously available public
build functionality without any deprecation path. This can break downstream Bazel code that loads
//dotnet:defs.bzl and expects nunit_test to exist.
Code

dotnet/defs.bzl[31]

-nunit_test = _nunit_test
Evidence
PR Compliance ID 8 requires deprecating public functionality before removal. dotnet/defs.bzl now
exports several symbols but no longer exports nunit_test, and other BUILD files load
//dotnet:defs.bzl, making removed exports potentially user-impacting.

AGENTS.md
dotnet/defs.bzl[19-30]
dotnet/test/webdriver/BUILD.bazel[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `nunit_test` symbol has been removed from `dotnet/defs.bzl` without a deprecation shim/message, which can break any Bazel users loading this macro.

## Issue Context
Repository policy requires deprecating public functionality before removal (the project does not strictly follow semver).

## Fix Focus Areas
- dotnet/defs.bzl[1-30]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Missing adapter MSBuild dep 🐞 Bug ≡ Correctness
Description
dotnet_nunit_test_suite compiles tests against the NUnit3TestAdapter runtime wrapper but does not
include Microsoft.Testing.Platform.MSBuild in the Bazel deps, even though NUnit3TestAdapter declares
it as a dependency. This can cause the test host to fail at runtime with missing-assembly load
errors when the adapter is initialized.
Code

dotnet/private/dotnet_nunit_test_suite.bzl[R135-141]

+_MTP_DEPS = [
+    "@paket.nuget//nunit",
+    "//dotnet/private:nunit3testadapter_runtime",
+    "@paket.nuget//microsoft.testing.platform",
+    "@paket.nuget//microsoft.testing.extensions.vstestbridge",
+    "@paket.nuget//microsoft.extensions.dependencymodel",
+]
Evidence
_MTP_DEPS omits Microsoft.Testing.Platform.MSBuild, but the repo’s Paket metadata shows
NUnit3TestAdapter depends on it. Because the adapter is brought in via a custom import_library (not
via @paket.nuget//nunit3testadapter where transitive deps would be wired), the MSBuild assembly
won’t be present unless explicitly added as a Bazel dep.

dotnet/private/dotnet_nunit_test_suite.bzl[135-141]
dotnet/paket.nuget.bzl[24-32]
dotnet/paket.lock[54-58]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`dotnet/private/dotnet_nunit_test_suite.bzl` adds the NUnit3TestAdapter DLLs via `//dotnet/private:nunit3testadapter_runtime`, but `_MTP_DEPS` does not include `Microsoft.Testing.Platform.MSBuild`, which is a declared dependency of `NUnit3TestAdapter`.

### Issue Context
Paket metadata in this repo shows `NUnit3TestAdapter` depends on `Microsoft.Testing.Platform.MSBuild`. Since the adapter is imported via a custom `import_library`, Bazel won’t automatically pull in that dependency unless it’s explicitly listed in the test binary’s deps.

### Fix Focus Areas
- dotnet/private/dotnet_nunit_test_suite.bzl[135-141]

### What to change
- Add `"@paket.nuget//microsoft.testing.platform.msbuild"` to `_MTP_DEPS` (and keep the rest as-is).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. mtp_shim.cs missing license header📘 Rule violation ⚙ Maintainability
Description
The newly added C# source file dotnet/private/mtp_shim.cs does not include the standard Apache 2.0
license header used throughout the repository. This can cause formatter/policy checks to fail and
creates licensing compliance risk.
Code

dotnet/private/mtp_shim.cs[R1-8]

+// Hand-ported equivalent of the source files normally generated by
+// Microsoft.Testing.Platform.MSBuild (TestingPlatformEntryPoint.cs and
+// SelfRegisteredExtensions.cs).
+//
+// Bazel's `csharp_test` invokes csc directly and never runs MSBuild, so the
+// MTP entry point + extension self-registration glue must be checked in.
+// Only the NUnit hook is registered: the MSBuild and Telemetry hooks add
+// nothing useful in a Bazel-driven test invocation.
Evidence
PR Compliance ID 5 requires required Apache license headers in new/modified source files.
dotnet/private/mtp_shim.cs begins with non-license comments and contains no Apache license header,
unlike typical C# files such as dotnet/src/webdriver/Alert.cs which include the expected header
block.

AGENTS.md
dotnet/private/mtp_shim.cs[1-8]
dotnet/src/webdriver/Alert.cs[1-18]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`dotnet/private/mtp_shim.cs` is a newly added C# source file but it does not include the standard Apache 2.0 license header required by repo policy.

## Issue Context
Other C# source files in this repository include an Apache 2.0 header block (e.g., `dotnet/src/webdriver/Alert.cs`). New source files should follow the same header format.

## Fix Focus Areas
- dotnet/private/mtp_shim.cs[1-22]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Quoted BrowserLocation parameter🐞 Bug ☼ Reliability
Description
The macOS Edge BrowserLocation test parameter is passed with literal surrounding quote characters,
so the parameter token is not plain BrowserLocation=<path>. If those quotes are not stripped by
the test-parameter parser, BrowserLocation will not be applied and EdgeOptions.BinaryLocation will
not point at the pinned Edge binary.
Code

dotnet/private/dotnet_nunit_test_suite.bzl[R45-49]

+                "--test-parameter",
+                "DriverServiceLocation=$(location @mac_edgedriver//:msedgedriver)",
+                "--test-parameter",
+                "\"BrowserLocation=$(location @mac_edge//:Edge.app)/Contents/MacOS/Microsoft Edge\"",
            ],
Evidence
The Bazel arg string for macOS Edge includes embedded quotes around the entire BrowserLocation=...
token. The test code expects a parameter named exactly BrowserLocation and uses it directly as
EdgeOptions.BinaryLocation with no trimming/sanitization; this makes the run sensitive to whether
the runner strips those quotes (and on non-Windows execution there is no shell layer to
interpret/remove them).

dotnet/private/dotnet_nunit_test_suite.bzl[44-49]
dotnet/private/dotnet_nunit_test_suite.bzl[143-152]
dotnet/test/webdriver/Infrastructure/Environment/EnvironmentManager.cs[56-60]
dotnet/test/webdriver/Infrastructure/Environment/DriverFactory.cs[98-110]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The macOS Edge `BrowserLocation` argument is currently passed as a string containing literal surrounding quote characters (e.g. `"BrowserLocation=...Microsoft Edge"`). This is unnecessary in Bazel arg lists and can prevent the parameter from being recognized cleanly.

### Issue Context
`EnvironmentManager` reads `TestContext.Parameters.Get("BrowserLocation", ...)` and `DriverFactory` assigns the resulting string directly to `EdgeOptions.BinaryLocation`.

### Fix Focus Areas
- dotnet/private/dotnet_nunit_test_suite.bzl[44-49]

### What to change
- Change the macOS Edge entry from a quoted token to a plain token:
 - from: `"BrowserLocation=.../Microsoft Edge"`
 - to: `BrowserLocation=.../Microsoft Edge`

Bazel will pass the entire string (including spaces) as a single argv element without requiring extra quoting.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the .NET test projects and Bazel NUnit test suite runner from the previous NUnitLite/MSBuild-based approach to the Microsoft Testing Platform (MTP), aligning CLI parameters, dependencies, and entry-point wiring for Bazel-driven test execution.

Changes:

  • Updated .NET test project files to enable MTP and bumped NUnit/NUnit3TestAdapter versions.
  • Reworked Bazel dotnet_nunit_test_suite to use an MTP entry-point shim and VSTest-style filtering/parameters.
  • Updated Paket dependencies/lock and Bazel module repos to include MTP + NUnit adapter requirements.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj Enables MTP runner settings; updates NUnit + adapter references.
dotnet/test/support/Selenium.WebDriver.Support.Tests.csproj Same MTP migration and package updates for Support tests.
dotnet/test/remote/Selenium.WebDriver.Remote.Tests.csproj Same MTP migration and package updates for Remote tests.
dotnet/test/webdriver/BUILD.bazel Removes direct Bazel dependency on NUnit package (now provided by suite rule).
dotnet/test/support/BUILD.bazel Removes direct Bazel dependency on NUnit package (now provided by suite rule).
dotnet/test/remote/BUILD.bazel Removes direct Bazel dependency on NUnit package (now provided by suite rule).
dotnet/private/nunit_test.bzl Removes obsolete NUnitLite shim-based test rule.
dotnet/private/mtp_shim.cs Adds checked-in MTP entry point for Bazel (no MSBuild codegen).
dotnet/private/dotnet_nunit_test_suite.bzl Switches runner args to MTP (--test-parameter, --filter) and adds MTP deps.
dotnet/private/BUILD.bazel Exports MTP shim and adds an adapter runtime wrapper via import_library.
dotnet/paket.dependencies Replaces NUnitLite with NUnit 4 + NUnit3TestAdapter + MTP packages.
dotnet/paket.lock Locks new dependency graph introduced by MTP + adapter.
dotnet/paket.nuget.bzl Updates Bazel-extracted NuGet metadata for the new packages.
dotnet/defs.bzl Removes export of the deleted nunit_test macro.
MODULE.bazel Adds a repo for nuget.nunit3testadapter.v6.2.0 used by the adapter runtime wrapper.

Comment thread dotnet/private/dotnet_nunit_test_suite.bzl Outdated
Comment thread dotnet/private/dotnet_nunit_test_suite.bzl Outdated
Comment thread dotnet/private/mtp_shim.cs Outdated
Comment thread dotnet/defs.bzl
Comment thread dotnet/private/dotnet_nunit_test_suite.bzl
Copilot AI review requested due to automatic review settings April 24, 2026 18:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Comment thread dotnet/private/dotnet_nunit_test_suite.bzl Outdated
Comment thread dotnet/private/dotnet_nunit_test_suite.bzl Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 19:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Comment thread dotnet/private/dotnet_nunit_test_suite.bzl
Comment thread dotnet/private/dotnet_nunit_test_suite.bzl
Copilot AI review requested due to automatic review settings April 24, 2026 21:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Comment thread dotnet/test/webdriver/Selenium.WebDriver.Tests.csproj
@nvborisenko nvborisenko merged commit ca2e49d into SeleniumHQ:trunk Apr 24, 2026
22 of 23 checks passed
@nvborisenko nvborisenko deleted the dotnet-test-mtp branch April 24, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-support Issue or PR related to support classes C-dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants