diff --git a/eng/restore-toolset.ps1 b/eng/restore-toolset.ps1
index e1ceb838b23..f2b5a2ddf60 100644
--- a/eng/restore-toolset.ps1
+++ b/eng/restore-toolset.ps1
@@ -4,15 +4,20 @@
# AFTER InitializeDotNetCli has bootstrapped the repo-local .dotnet/ SDK, so
# $RepoRoot and the helpers from eng/common/tools.ps1 are in scope.
#
-# Required by the wasi-wasm acceptance tests:
+# Required by the wasm acceptance tests (and the browser-wasm sample):
# - test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/WasmExecutionTests.cs
# - test/IntegrationTests/MSTest.Acceptance.IntegrationTests/WasmExecutionTests.cs
-# Their generated assets set true; the
-# `wasi-experimental-net10` workload is needed by the always-on `dotnet build -r wasi-wasm` assertions
-# (otherwise NETSDK1147 in CI), and `wasm-tools-net10` is needed by the gated `dotnet publish -r
-# wasi-wasm` step the execution tests perform (otherwise the publish fails and they self-skip).
-# Running the execution tests to completion additionally needs `wasmtime` on PATH; when it is absent
-# the tests mark themselves inconclusive.
+# - test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs
+# - samples/BrowserPlayground
+# `wasi-experimental-net10` is needed by the always-on `dotnet build -r wasi-wasm` assertions, whose
+# generated asset sets true (see WasmExecutionTests.cs);
+# otherwise NETSDK1147 in CI. `wasm-tools-net10` is needed by the gated `dotnet publish -r wasi-wasm` step the
+# wasi execution tests perform AND by the browser-wasm build/publish path (BrowserWasmExecutionTests /
+# BrowserPlayground) — for browser-wasm it is required even by `dotnet build`. Installing it here means CI
+# actually exercises the browser-wasm build (and, where 'node' is present, the end-to-end run) instead of the
+# acceptance test silently going Inconclusive on every leg. Running the wasi execution tests to completion
+# additionally needs `wasmtime` on PATH; when it (or `node`, for browser-wasm) is absent the tests mark
+# themselves inconclusive.
$RequiredWorkloads = @('wasi-experimental-net10', 'wasm-tools-net10')
diff --git a/eng/restore-toolset.sh b/eng/restore-toolset.sh
index 274cf56866e..bf21340a515 100644
--- a/eng/restore-toolset.sh
+++ b/eng/restore-toolset.sh
@@ -6,15 +6,20 @@
# AFTER InitializeDotNetCli has bootstrapped the repo-local .dotnet/ SDK, so
# $repo_root and the helpers from eng/common/tools.sh are in scope.
#
-# Required by the wasi-wasm acceptance tests:
+# Required by the wasm acceptance tests (and the browser-wasm sample):
# - test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/WasmExecutionTests.cs
# - test/IntegrationTests/MSTest.Acceptance.IntegrationTests/WasmExecutionTests.cs
-# Their generated assets set true; the
-# `wasi-experimental-net10` workload is needed by the always-on `dotnet build -r wasi-wasm` assertions
-# (otherwise NETSDK1147 in CI), and `wasm-tools-net10` is needed by the gated `dotnet publish -r
-# wasi-wasm` step the execution tests perform (otherwise the publish fails and they self-skip).
-# Running the execution tests to completion additionally needs `wasmtime` on PATH; when it is absent
-# the tests mark themselves inconclusive.
+# - test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs
+# - samples/BrowserPlayground
+# `wasi-experimental-net10` is needed by the always-on `dotnet build -r wasi-wasm` assertions, whose
+# generated asset sets true (see WasmExecutionTests.cs);
+# otherwise NETSDK1147 in CI. `wasm-tools-net10` is needed by the gated `dotnet publish -r wasi-wasm` step the
+# wasi execution tests perform AND by the browser-wasm build/publish path (BrowserWasmExecutionTests /
+# BrowserPlayground) — for browser-wasm it is required even by `dotnet build`. Installing it here means CI
+# actually exercises the browser-wasm build (and, where 'node' is present, the end-to-end run) instead of the
+# acceptance test silently going Inconclusive on every leg. Running the wasi execution tests to completion
+# additionally needs `wasmtime` on PATH; when it (or `node`, for browser-wasm) is absent the tests mark
+# themselves inconclusive.
required_workloads=('wasi-experimental-net10' 'wasm-tools-net10')
diff --git a/samples/BrowserPlayground/BrowserPlayground.csproj b/samples/BrowserPlayground/BrowserPlayground.csproj
new file mode 100644
index 00000000000..a9514af04ac
--- /dev/null
+++ b/samples/BrowserPlayground/BrowserPlayground.csproj
@@ -0,0 +1,63 @@
+
+
+
+ Exe
+ net10.0
+ browser-wasm
+
+ true
+
+
+ wwwroot\main.js
+
+
+ false
+ false
+
+ enable
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/BrowserPlayground/Program.cs b/samples/BrowserPlayground/Program.cs
new file mode 100644
index 00000000000..823cce8dd36
--- /dev/null
+++ b/samples/BrowserPlayground/Program.cs
@@ -0,0 +1,62 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.Testing.Extensions;
+using Microsoft.Testing.Platform.Builder;
+using Microsoft.Testing.Platform.Capabilities.TestFramework;
+using Microsoft.Testing.Platform.Extensions.Messages;
+using Microsoft.Testing.Platform.Extensions.TestFramework;
+
+ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);
+
+testApplicationBuilder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, _) => new DummyFramework());
+
+testApplicationBuilder.AddAppInsightsTelemetryProvider();
+
+// The following extensions are intentionally NOT registered on browser-wasm:
+// - AddTrxReportProvider: with --report-trx enabled, TrxDataConsumer creates a
+// TrxResultStreamingStore whose background writer calls ITask.RunLongRunning (and uses
+// BlockingCollection), both unsupported on browser; the TRX lifecycle handlers are
+// themselves gated by OperatingSystem.IsBrowser() (see TrxReportExtensions). Registering it
+// would let a user pass --report-trx and hit PlatformNotSupportedException.
+// - AddHangDumpProvider / AddCrashDumpProvider: dumps rely on System.Diagnostics.Process,
+// which is unsupported in the browser sandbox (see #8557).
+// - AddAzureDevOpsProvider: its HttpClient sets AutomaticDecompression, which the browser
+// HttpClientHandler does not support.
+// Threading is not an issue for the registered providers: the platform detects the
+// single-threaded wasm runtime (RuntimeFeatureHelper.IsMultiThreaded == false) and runs the
+// pipeline inline, exactly as it does on wasi-wasm.
+using ITestApplication testApplication = await testApplicationBuilder.BuildAsync();
+return await testApplication.RunAsync();
+
+internal sealed class DummyFramework : ITestFramework, IDataProducer
+{
+ public string Uid => nameof(DummyFramework);
+
+ public string Version => "1.0.0";
+
+ public string DisplayName => "DummyFramework";
+
+ public string Description => DisplayName;
+
+ public Type[] DataTypesProduced => [typeof(TestNodeUpdateMessage)];
+
+ public Task CloseTestSessionAsync(CloseTestSessionContext context)
+ => Task.FromResult(new CloseTestSessionResult() { IsSuccess = true });
+
+ public Task CreateTestSessionAsync(CreateTestSessionContext context)
+ => Task.FromResult(new CreateTestSessionResult() { IsSuccess = true });
+
+ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
+ {
+ await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode()
+ {
+ DisplayName = "Test display name",
+ Uid = "Uid1",
+ Properties = new PropertyBag(PassedTestNodeStateProperty.CachedInstance),
+ }));
+ context.Complete();
+ }
+
+ public Task IsEnabledAsync() => Task.FromResult(true);
+}
diff --git a/samples/BrowserPlayground/README.md b/samples/BrowserPlayground/README.md
new file mode 100644
index 00000000000..df47ffba2d1
--- /dev/null
+++ b/samples/BrowserPlayground/README.md
@@ -0,0 +1,152 @@
+# BrowserPlayground
+
+Demonstrates hosting [Microsoft.Testing.Platform](https://aka.ms/testingplatform/) on
+`browser-wasm` — the WebAssembly runtime that runs inside a browser (and, headlessly,
+under [Node.js](https://nodejs.org/) via the same `dotnet.js` loader).
+
+This is the browser counterpart to the `wasi-wasm` acceptance coverage in
+[`WasmExecutionTests.cs`](../../test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/WasmExecutionTests.cs)
+(and its MSTest sibling under `MSTest.Acceptance.IntegrationTests`). Both `wasi-wasm` and
+`browser-wasm` run on a single-threaded WebAssembly runtime; the platform work that makes
+that possible is shared (see [#2196](https://github.com/microsoft/testfx/issues/2196)). The
+only real difference is the **host**: `wasi-wasm` runs headless under `wasmtime`, whereas
+`browser-wasm` boots through a small JavaScript module (`wwwroot/main.js`) that loads
+`dotnet.js` and invokes the sample's `Program.Main` (defined by the top-level statements
+in `Program.cs`).
+
+## Build & run
+
+> **Not part of `TestFx.slnx`.** `browser-wasm` needs the `wasm-tools` workload even to
+> *build*. The repo bootstrap (`.\build.cmd` / `./build.sh`) installs that workload via
+> `eng/restore-toolset`, so a bootstrapped build already has it. It is kept out of the
+> solution to protect **builds that bypass the bootstrap** — most notably opening
+> `TestFx.slnx` in an IDE on a fresh clone, or any environment where the workload has not
+> been installed — from failing the whole solution build. So `BrowserPlayground` is built
+> on demand with the explicit `dotnet publish` below rather than as part of the solution.
+
+Prerequisites:
+
+- The repo-local .NET SDK (`.dotnet\dotnet.exe` on Windows, `.dotnet/dotnet` on
+ Linux/macOS). Bootstrap it once by running `.\build.cmd` (Windows) or `./build.sh`
+ (Linux/macOS) from the repo root. The bootstrap also installs the `wasm-tools-net10`
+ workload this sample needs (see
+ [`eng/restore-toolset.ps1`](../../eng/restore-toolset.ps1) /
+ [`eng/restore-toolset.sh`](../../eng/restore-toolset.sh)). If you use a machine-installed
+ SDK instead, install the workload manually:
+
+ ```sh
+ dotnet workload install wasm-tools-net10
+ ```
+
+- For the headless run: [Node.js](https://nodejs.org/) on `PATH`.
+ For the browser run: any static web server (see step 2b).
+
+> The commands below use the repo-local SDK so the `.dotnet/packs` lookup resolves — that
+> is `.\.dotnet\dotnet.exe` on Windows and `./.dotnet/dotnet` on Linux/macOS (shown as
+> `dotnet` below for brevity). Swap in a machine-installed `dotnet` if you prefer. The paths
+> below use forward slashes, which work on all platforms; on Windows you can also use `\`.
+
+### 1. Publish
+
+```sh
+dotnet publish samples/BrowserPlayground/BrowserPlayground.csproj -c Debug -f net10.0
+```
+
+The published app bundle lands under
+`artifacts/bin/BrowserPlayground/Debug/net10.0/browser-wasm/AppBundle` and contains
+`_framework/dotnet.js`, the managed assemblies, `index.html`, `main.js`, and
+`runtests.mjs`.
+
+### 2a. Run headlessly under Node
+
+From the bundle directory:
+
+```sh
+cd artifacts/bin/BrowserPlayground/Debug/net10.0/browser-wasm/AppBundle
+node runtests.mjs
+```
+
+`runtests.mjs` boots the same bundle under Node (no DOM required — Microsoft.Testing.Platform
+never touches the DOM), forwards stdout/stderr, and maps the .NET exit code onto the Node
+process exit code. This is the mode the `BrowserWasmExecutionTests` acceptance test uses.
+
+### 2b. Run in a browser
+
+Serve the bundle over HTTP (WebAssembly cannot be loaded from `file://`) and open it. Any
+static file server works; two options that need no extra provisioning:
+
+```sh
+cd artifacts/bin/BrowserPlayground/Debug/net10.0/browser-wasm/AppBundle
+
+# Using Node (installed for step 2a):
+npx --yes http-server -o
+
+# ...or using Python 3:
+python3 -m http.server 8080
+```
+
+Then browse to the served URL (`http-server` opens it automatically; for the Python server
+open ). The test run output appears in the browser's developer-tools
+**Console**. Pass Microsoft.Testing.Platform options through the page query string, e.g.
+`index.html?arg=--minimum-expected-tests&arg=1`.
+
+## Status
+
+Microsoft.Testing.Platform boots on `browser-wasm` (the banner reads
+`[browser-wasm - net10.0]`) and tests run to completion, exactly as on `wasi-wasm`.
+Running this sample — which hosts a `DummyFramework` with a single passing test —
+produces:
+
+```console
+Test run summary: Passed!
+ total: 1
+ failed: 0
+ succeeded: 1
+ skipped: 0
+```
+
+MSTest itself (not just the raw platform) also runs end-to-end on `browser-wasm`; that
+is covered by the gated `BrowserWasmExecutionTests.BrowserWasmExecution_RunsTestsUnderNode`
+acceptance test (see
+[`test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs`](../../test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs)),
+which publishes a real MSTest project and runs it under Node.
+
+### Why it works
+
+The single-threaded WebAssembly constraint is the same as `wasi-wasm`: there is no
+thread pool, so `Task.Run` continuations never execute and blocking waits throw
+`PlatformNotSupportedException`. The platform and the MSTest adapter detect this
+(`RuntimeFeatureHelper.IsMultiThreaded` / `RuntimeContext.IsMultiThreaded`, derived from
+`OperatingSystem.IsBrowser()`) and fall back to inline/synchronous execution on the run
+path — the message-bus consumers, the shutdown watchdog, the telemetry ingest loop, the
+countdown-event wait, and the adapter's per-test task factory.
+
+Console output is routed through `BrowserOutputDevice`, which forwards to the browser's
+`globalThis.console.*` APIs via `[JSImport]`.
+
+### Feature matrix (what is *not* available on browser-wasm)
+
+Several extensions/capabilities are intentionally unavailable in the browser sandbox and
+are guarded off by `OperatingSystem.IsBrowser()` in the platform:
+
+| Feature | Reason |
+| --- | --- |
+| TRX report (`--report-trx`) | `TrxDataConsumer` creates a `TrxResultStreamingStore` whose background writer uses `BlockingCollection` and `ITask.RunLongRunning`, both unsupported on browser; the TRX lifecycle handlers are gated by `OperatingSystem.IsBrowser()`. |
+| Hang dump / crash dump | Rely on `System.Diagnostics.Process`, unsupported in the browser (see [#8557](https://github.com/microsoft/testfx/issues/8557)). |
+| Azure DevOps report | Its `HttpClient` sets `AutomaticDecompression`, unsupported by the browser `HttpClientHandler`. |
+| Server mode / `dotnet test` pipe | Depends on TCP/named-pipe IPC, unavailable in the browser. |
+| `--exit-on-process-exit`, wait-for-debugger | No host process model in the browser. |
+| Synchronous file-logger flush | Not supported in the browser (throws `PlatformNotSupportedException`). |
+
+That is why `Program.cs` registers only the telemetry provider (`AddAppInsightsTelemetryProvider`).
+
+## Build configuration notes
+
+`BrowserPlayground.csproj` ships with a few non-obvious switches:
+
+| Property | Reason |
+| --- | --- |
+| `SelfContained=true` | Publishing browser-wasm must be self-contained so the `Microsoft.NETCore.App.Runtime.Mono.browser-wasm` runtime pack is resolved. Targeting `net10.0` under an `11.0` SDK does not infer this on its own, so publish fails with an empty `MicrosoftNetCoreAppRuntimePackDir` without it. |
+| `WasmBuildNative=false` | Use the pre-built `dotnet.native.wasm`. A native relink needs the emscripten toolchain (pulled in by the `wasm-tools` workload) and is slower; the pre-built runtime is enough to boot MTP. |
+| (no `InvariantGlobalization`) | On browser-wasm, `InvariantGlobalization=true` forces `WasmBuildNative=true` (an emscripten relink), so it is intentionally left unset — the browser bundle ships ICU (`icudt*.dat`) by default. This differs from the `wasi-wasm` acceptance asset (`WasmExecutionTests.cs`), which keeps `InvariantGlobalization=true` and stages `icudt.dat` manually via `WasmRuntime.StageIcuData`. |
+| `WasmExtraFilesToDeploy` | Copies the node runner (`runtests.mjs`) and `index.html` into the published `AppBundle` next to `main.js` (the `WasmMainJSPath` module). Plain `CopyToOutputDirectory` would only reach the build output folder, not the `AppBundle`. |
diff --git a/samples/BrowserPlayground/wwwroot/index.html b/samples/BrowserPlayground/wwwroot/index.html
new file mode 100644
index 00000000000..4f53a305c63
--- /dev/null
+++ b/samples/BrowserPlayground/wwwroot/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+ BrowserPlayground
+
+
+
+
Running Microsoft.Testing.Platform on browser-wasm. Open the developer-tools console to see the test run output.
+
+
+
+
+
diff --git a/samples/BrowserPlayground/wwwroot/main.js b/samples/BrowserPlayground/wwwroot/main.js
new file mode 100644
index 00000000000..a212ad18067
--- /dev/null
+++ b/samples/BrowserPlayground/wwwroot/main.js
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// Browser boot module. The WebAssembly runtime loads this file first (it is the
+// project's WasmMainJSPath). It creates the .NET runtime through dotnet.js and runs the
+// sample's Program.Main (defined by the top-level statements in Program.cs), which boots
+// Microsoft.Testing.Platform.
+import { dotnet } from './_framework/dotnet.js';
+
+const { runMain } = await dotnet
+ // A browser page has no argv, so Microsoft.Testing.Platform command-line options are
+ // taken from the page's query string, e.g.:
+ // index.html?arg=--minimum-expected-tests&arg=1
+ .withApplicationArgumentsFromQuery()
+ .create();
+
+// runMain() invokes Program.Main and resolves to its exit code (0 = all tests passed,
+// non-zero = failures / policy violation).
+const exitCode = await runMain();
+
+// Surface the result so a headless browser driver (Playwright/Puppeteer) can read it,
+// and so a human sees it in the dev-tools console / tab title.
+console.log(`Microsoft.Testing.Platform exit code: ${exitCode}`);
+globalThis.mtpExitCode = exitCode;
+document.title = `exit:${exitCode}`;
diff --git a/samples/BrowserPlayground/wwwroot/runtests.mjs b/samples/BrowserPlayground/wwwroot/runtests.mjs
new file mode 100644
index 00000000000..cf1ff2a7ac3
--- /dev/null
+++ b/samples/BrowserPlayground/wwwroot/runtests.mjs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// Headless node runner for the browser-wasm bundle.
+//
+// browser-wasm normally boots inside a browser, but Microsoft.Testing.Platform never
+// touches the DOM, so the same bundle boots under node via the dotnet.js loader. This
+// gives a CI-friendly, headless way to run the tests where the .NET exit code becomes
+// the node process exit code and stdout/stderr flow straight through — no browser or
+// web server required.
+//
+// Usage (from the published AppBundle folder, i.e. next to _framework/):
+// node runtests.mjs [mtp-args...]
+//
+// e.g. node runtests.mjs --minimum-expected-tests 1
+import { dotnet } from './_framework/dotnet.js';
+
+const { runMain } = await dotnet
+ .withApplicationArguments(...process.argv.slice(2))
+ .create();
+
+// runMain() boots the same bundle under Node and resolves to the exit code of the sample's
+// Program.Main (defined by the top-level statements in Program.cs).
+const exitCode = await runMain();
+
+// Set exitCode rather than calling process.exit(): process.exit() can terminate Node before
+// redirected stdout/stderr has flushed (which would truncate the MTP output this runner promises
+// to surface). Setting exitCode lets Node drain its streams and exit with the .NET result.
+process.exitCode = exitCode;
diff --git a/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt b/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt
index 9f21d61ce63..19f082152af 100644
--- a/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt
+++ b/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt
@@ -1,4 +1,5 @@
#nullable enable
+abstract Microsoft.Testing.Extensions.RunSettingsCommandLineOptionsProviderBase.EnvironmentVariablesNotSupportedOnBrowserError.get -> string!
abstract Microsoft.Testing.Extensions.RunSettingsConfigurationProviderBase.DisplayName.get -> string!
abstract Microsoft.Testing.Extensions.RunSettingsConfigurationProviderBase.ReadRunSettings(Microsoft.Testing.Platform.CommandLine.CommandLineParseResult! commandLineParseResult) -> string?
abstract Microsoft.Testing.Extensions.RunSettingsConfigurationProviderBase.Uid.get -> string!
@@ -27,9 +28,11 @@ Microsoft.Testing.Extensions.RunSettingsProviderHelper
Microsoft.VisualStudio.TestTools.UnitTesting.PlatformServicesConfigurationAdapter
Microsoft.VisualStudio.TestTools.UnitTesting.PlatformServicesConfigurationAdapter.PlatformServicesConfigurationAdapter(Microsoft.Testing.Platform.Configurations.IConfiguration! configuration) -> void
Microsoft.VisualStudio.TestTools.UnitTesting.PlatformServicesConfigurationAdapter.this[string! key].get -> string?
+override Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestingPlatformAdapter.MSTestRunSettingsCommandLineOptionsProvider.EnvironmentVariablesNotSupportedOnBrowserError.get -> string!
override Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestingPlatformAdapter.MSTestRunSettingsConfigurationProvider.DisplayName.get -> string!
override Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestingPlatformAdapter.MSTestRunSettingsConfigurationProvider.Uid.get -> string!
override Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestingPlatformAdapter.MSTestRunSettingsConfigurationProvider.Version.get -> string!
+override sealed Microsoft.Testing.Extensions.RunSettingsCommandLineOptionsProviderBase.ValidateCommandLineOptionsAsync(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions) -> System.Threading.Tasks.Task!
override sealed Microsoft.Testing.Extensions.RunSettingsCommandLineOptionsProviderBase.ValidateOptionArgumentsAsync(Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption! commandOption, string![]! arguments) -> System.Threading.Tasks.Task!
static Microsoft.Testing.Extensions.RunSettingsProviderHelper.ApplyEnvironmentVariables(System.Xml.Linq.XDocument! runSettings, Microsoft.Testing.Platform.Extensions.TestHostControllers.IEnvironmentVariables! environmentVariables) -> void
static Microsoft.Testing.Extensions.RunSettingsProviderHelper.CanReadFile(Microsoft.Testing.Platform.Helpers.IFileSystem! fileSystem, string! filePath) -> bool
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/PlatformAdapterResources.resx b/src/Adapter/MSTest.TestAdapter/Resources/PlatformAdapterResources.resx
index c682da555cb..078c3d4338f 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/PlatformAdapterResources.resx
+++ b/src/Adapter/MSTest.TestAdapter/Resources/PlatformAdapterResources.resx
@@ -121,6 +121,10 @@
runsettings file '{0}' cannot be read0 is the {Locked="runsettings"} file path.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+
runsettings file '{0}' does not exist0 is the {Locked="runsettings"} file path.
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.cs.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.cs.xlf
index 1c55430bd7e..2c2e5067ba8 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.cs.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.cs.xlf
@@ -7,6 +7,11 @@
Neplatný soubor .runsettings. Chybí atribut <RunSettings>.Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileRelativní nebo absolutní cesta k souboru .runsettings. Další informace a příklady konfigurace testovacího běhu najdete v tématu https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.de.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.de.xlf
index 8572c885708..1217b46e214 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.de.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.de.xlf
@@ -7,6 +7,11 @@
Ungültige .runsettings-Datei, "<RunSettings>"-Attribut fehlt.Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileDer relative oder absolute Pfad zur Datei „.runsettings“. Weitere Informationen und Beispiele zum Konfigurieren des Testlaufs finden Sie unter https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.es.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.es.xlf
index 886679c3234..491867c084e 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.es.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.es.xlf
@@ -7,6 +7,11 @@
Archivo .runsettings no válido, falta el atributo "<RunSettings>"Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileRuta de acceso, relativa o absoluta, al archivo .runsettings. Para obtener más información y ejemplos sobre cómo configurar la serie de pruebas, consulte https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.fr.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.fr.xlf
index e337095d286..8776901f47c 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.fr.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.fr.xlf
@@ -7,6 +7,11 @@
Fichier .runsettings non valide, « <RunSettings> » attribut est manquantDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileChemin d’accès, relatif ou absolu, au fichier .runsettings. Pour plus d’informations et d’exemples sur la configuration de la série de tests, consultez https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.it.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.it.xlf
index f246accfd3d..3492b1cc5fc 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.it.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.it.xlf
@@ -7,6 +7,11 @@
File .runsettings non valido. Attributo '<RunSettings>' mancanteDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-filePercorso, relativo o assoluto, del file .runsettings. Per altre informazioni ed esempi su come configurare l'esecuzione dei test, vedere https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ja.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ja.xlf
index 707ee8e6816..43e96e80c2b 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ja.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ja.xlf
@@ -7,6 +7,11 @@
.runsettings ファイルが無効です。'<RunSettings>' 属性がありませんDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings ファイルへの相対パスまたは絶対パス。テストの実行を構成する方法の詳細と例については、https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file を参照してください
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ko.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ko.xlf
index bf2bc8c1c8d..e5ccb65fa2c 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ko.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ko.xlf
@@ -7,6 +7,11 @@
.runsettings 파일이 잘못되었습니다. '<RunSettings>' 특성이 없습니다.Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings 파일에 대한 상대 또는 절대 경로입니다. 테스트 실행을 구성하는 방법에 관한 자세한 내용 및 예시는 https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file을 참조하세요.
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pl.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pl.xlf
index 97e68a08935..60bac2c7ad0 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pl.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pl.xlf
@@ -7,6 +7,11 @@
Nieprawidłowy plik .runsettings, brak atrybutu „<RunSettings>”Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileŚcieżka względna lub bezwzględna pliku .runsettings. Aby uzyskać więcej informacji i przykładów dotyczących konfigurowania przebiegu testu, zobacz: https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pt-BR.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pt-BR.xlf
index 9c540583670..0b018047f20 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pt-BR.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.pt-BR.xlf
@@ -7,6 +7,11 @@
Arquivo .runsettings inválido, o atributo "<RunSettings>" está ausenteDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileO caminho, relativo ou absoluto, para o arquivo .runsettings. Para obter mais informações e exemplos sobre como configurar a execução de teste, consulte https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ru.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ru.xlf
index 63f0fe22d84..35803f4b515 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ru.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.ru.xlf
@@ -7,6 +7,11 @@
Недопустимый файл .runsettings, отсутствует атрибут "<RunSettings>"Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileОтносительный или абсолютный путь к файлу .runsettings. Дополнительные сведения и примеры настройки тестового запуска см. на странице https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.tr.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.tr.xlf
index 643a979008a..ec55b157c4a 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.tr.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.tr.xlf
@@ -7,6 +7,11 @@
Geçersiz .runsettings dosyası, '<RunSettings>' özniteliği eksikDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings dosyasının göreli veya mutlak yolu. Test çalıştırmasını yapılandırma hakkında daha fazla bilgi ve örnek için şu sayfaya bakın: https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hans.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hans.xlf
index 00d6f1cce80..ae65dfe275f 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hans.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hans.xlf
@@ -7,6 +7,11 @@
.runsettings 文件无效,缺少 '<RunSettings>' 属性Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings 文件的相对路径或绝对路径。有关如何配置测试运行的详细信息和示例,请参阅 https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hant.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hant.xlf
index a505d399a06..02aae877d3e 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hant.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/PlatformAdapterResources.zh-Hant.xlf
@@ -7,6 +7,11 @@
.runsettings 檔案無效,遺漏 '<RunSettings>' 屬性Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings 檔案的相對或絕對路徑。如需如何設定測試回合的詳細資訊和範例,請參閱 https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestRunSettingsCommandLineOptionsProvider.cs b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestRunSettingsCommandLineOptionsProvider.cs
index 28482abf6ac..2dae388e9bb 100644
--- a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestRunSettingsCommandLineOptionsProvider.cs
+++ b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestRunSettingsCommandLineOptionsProvider.cs
@@ -28,5 +28,7 @@ internal MSTestRunSettingsCommandLineOptionsProvider(IExtension extension, IFile
: base(extension, fileSystem, PlatformAdapterResources.RunSettingsOptionDescription, PlatformAdapterResources.RunsettingsFileDoesNotExist, PlatformAdapterResources.RunsettingsFileCannotBeRead)
{
}
+
+ protected override string EnvironmentVariablesNotSupportedOnBrowserError => PlatformAdapterResources.RunSettingsEnvironmentVariablesNotSupportedOnBrowser;
}
#endif
diff --git a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/TestApplicationBuilderExtensions.cs b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/TestApplicationBuilderExtensions.cs
index ad0e56decd1..c0b608a5a92 100644
--- a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/TestApplicationBuilderExtensions.cs
+++ b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/TestApplicationBuilderExtensions.cs
@@ -51,8 +51,21 @@ public static void AddMSTest(this ITestApplicationBuilder testApplicationBuilder
testApplicationBuilder.CommandLine.AddProvider(() => new MSTestTestCaseFilterCommandLineOptionsProvider(extension));
testApplicationBuilder.CommandLine.AddProvider(() => new MSTestTestRunParametersCommandLineOptionsProvider(extension));
testApplicationBuilder.AddMaximumFailedTestsService(extension);
- testApplicationBuilder.TestHostControllers.AddEnvironmentVariableProvider(serviceProvider
- => new MSTestRunSettingsEnvironmentVariableProvider(extension, serviceProvider.GetCommandLineOptions(), serviceProvider.GetFileSystem(), serviceProvider.GetEnvironment()));
+
+ // The environment-variable provider is a test-host-controller extension: it applies runsettings
+ // by relaunching the test host with those variables set. That requires a
+ // controller process + restart, which browser-wasm does not support (TestHostControllersManager
+ // throws PlatformNotSupportedException there). Skip the registration on browser. Silently dropping
+ // a requested section would change test semantics, so
+ // RunSettingsCommandLineOptionsProviderBase.ValidateCommandLineOptionsAsync fails with a clear
+ // unsupported-platform diagnostic when the resolved runsettings (from --settings or either
+ // runsettings environment variable) actually declares that section on browser.
+ // See https://github.com/microsoft/testfx/issues/2196.
+ if (!OperatingSystem.IsBrowser())
+ {
+ testApplicationBuilder.TestHostControllers.AddEnvironmentVariableProvider(serviceProvider
+ => new MSTestRunSettingsEnvironmentVariableProvider(extension, serviceProvider.GetCommandLineOptions(), serviceProvider.GetFileSystem(), serviceProvider.GetEnvironment()));
+ }
// MSTest plugs into Microsoft.Testing.Platform directly (no VSTest bridge object model on the request path).
testApplicationBuilder.RegisterTestFramework(
diff --git a/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs b/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs
index a84a7ec7d46..1b408d702c5 100644
--- a/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs
+++ b/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs
@@ -3,6 +3,10 @@
using Microsoft.Testing.Platform.Builder;
+#if !NETCOREAPP
+using Polyfills;
+#endif
+
namespace Microsoft.Testing.Platform.MSBuild;
///
@@ -15,7 +19,19 @@ public static class TestingPlatformBuilderHook
///
/// The test application builder.
/// The command line arguments.
- [UnsupportedOSPlatform("browser")]
public static void AddExtensions(ITestApplicationBuilder testApplicationBuilder, string[] _)
- => testApplicationBuilder.AddMSBuild();
+ {
+ // The MSBuild extension provides the `dotnet test` / MSBuild-node integration, which relies on
+ // named-pipe IPC that is unavailable on browser-wasm. This hook is auto-registered for every
+ // MSTest runner app (via the generated SelfRegisteredExtensions, because MSTest.TestAdapter
+ // references Microsoft.Testing.Platform.MSBuild), so skip it on browser instead of throwing —
+ // otherwise every browser-wasm test app crashes at startup. See
+ // https://github.com/microsoft/testfx/issues/2196.
+ if (OperatingSystem.IsBrowser())
+ {
+ return;
+ }
+
+ testApplicationBuilder.AddMSBuild();
+ }
}
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/RunSettingsCommandLineOptionsProvider.cs b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/RunSettingsCommandLineOptionsProvider.cs
index 8fcee9b0deb..534194940e8 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/RunSettingsCommandLineOptionsProvider.cs
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/RunSettingsCommandLineOptionsProvider.cs
@@ -21,4 +21,6 @@ public RunSettingsCommandLineOptionsProvider(IExtension extension)
: base(extension, fileSystem, ExtensionResources.RunSettingsOptionDescription, ExtensionResources.RunsettingsFileDoesNotExist, ExtensionResources.RunsettingsFileCannotBeRead)
{
}
+
+ protected override string EnvironmentVariablesNotSupportedOnBrowserError => ExtensionResources.RunSettingsEnvironmentVariablesNotSupportedOnBrowser;
}
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt
index 9981af5abb9..3b754cd2f7a 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt
@@ -1,4 +1,5 @@
#nullable enable
+abstract Microsoft.Testing.Extensions.RunSettingsCommandLineOptionsProviderBase.EnvironmentVariablesNotSupportedOnBrowserError.get -> string!
abstract Microsoft.Testing.Extensions.RunSettingsConfigurationProviderBase.DisplayName.get -> string!
abstract Microsoft.Testing.Extensions.RunSettingsConfigurationProviderBase.ReadRunSettings(Microsoft.Testing.Platform.CommandLine.CommandLineParseResult! commandLineParseResult) -> string?
abstract Microsoft.Testing.Extensions.RunSettingsConfigurationProviderBase.Uid.get -> string!
@@ -27,9 +28,11 @@ Microsoft.Testing.Extensions.RunSettingsProviderHelper
Microsoft.Testing.Extensions.VSTestBridge.ObjectModel.ContextAdapterBase.ContextAdapterBase(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings! runSettings, Microsoft.Testing.Platform.Requests.ITestExecutionFilter! filter, bool useFullyQualifiedNameAsUid) -> void
Microsoft.Testing.Extensions.VSTestBridge.ObjectModel.DiscoveryContextAdapter.DiscoveryContextAdapter(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings! runSettings, Microsoft.Testing.Platform.Requests.ITestExecutionFilter! filter, bool useFullyQualifiedNameAsUid) -> void
Microsoft.Testing.Extensions.VSTestBridge.ObjectModel.RunContextAdapter.RunContextAdapter(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings! runSettings, Microsoft.Testing.Platform.Requests.ITestExecutionFilter! filter, bool useFullyQualifiedNameAsUid) -> void
+override Microsoft.Testing.Extensions.VSTestBridge.CommandLine.RunSettingsCommandLineOptionsProvider.EnvironmentVariablesNotSupportedOnBrowserError.get -> string!
override Microsoft.Testing.Extensions.VSTestBridge.Configurations.RunSettingsConfigurationProvider.DisplayName.get -> string!
override Microsoft.Testing.Extensions.VSTestBridge.Configurations.RunSettingsConfigurationProvider.Uid.get -> string!
override Microsoft.Testing.Extensions.VSTestBridge.Configurations.RunSettingsConfigurationProvider.Version.get -> string!
+override sealed Microsoft.Testing.Extensions.RunSettingsCommandLineOptionsProviderBase.ValidateCommandLineOptionsAsync(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions) -> System.Threading.Tasks.Task!
override sealed Microsoft.Testing.Extensions.RunSettingsCommandLineOptionsProviderBase.ValidateOptionArgumentsAsync(Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption! commandOption, string![]! arguments) -> System.Threading.Tasks.Task!
static Microsoft.Testing.Extensions.RunSettingsProviderHelper.ApplyEnvironmentVariables(System.Xml.Linq.XDocument! runSettings, Microsoft.Testing.Platform.Extensions.TestHostControllers.IEnvironmentVariables! environmentVariables) -> void
static Microsoft.Testing.Extensions.RunSettingsProviderHelper.CanReadFile(Microsoft.Testing.Platform.Helpers.IFileSystem! fileSystem, string! filePath) -> bool
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/ExtensionResources.resx b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/ExtensionResources.resx
index c682da555cb..078c3d4338f 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/ExtensionResources.resx
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/ExtensionResources.resx
@@ -121,6 +121,10 @@
runsettings file '{0}' cannot be read0 is the {Locked="runsettings"} file path.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+
runsettings file '{0}' does not exist0 is the {Locked="runsettings"} file path.
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.cs.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.cs.xlf
index 12f3d80478d..27400bbefa5 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.cs.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.cs.xlf
@@ -7,6 +7,11 @@
Neplatný soubor .runsettings. Chybí atribut <RunSettings>.Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileRelativní nebo absolutní cesta k souboru .runsettings. Další informace a příklady konfigurace testovacího běhu najdete v tématu https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.de.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.de.xlf
index 4ed53937ce8..8344f07deaf 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.de.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.de.xlf
@@ -7,6 +7,11 @@
Ungültige .runsettings-Datei, "<RunSettings>"-Attribut fehlt.Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileDer relative oder absolute Pfad zur Datei „.runsettings“. Weitere Informationen und Beispiele zum Konfigurieren des Testlaufs finden Sie unter https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.es.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.es.xlf
index edb951940c5..80edceccf0b 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.es.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.es.xlf
@@ -7,6 +7,11 @@
Archivo .runsettings no válido, falta el atributo "<RunSettings>"Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileRuta de acceso, relativa o absoluta, al archivo .runsettings. Para obtener más información y ejemplos sobre cómo configurar la serie de pruebas, consulte https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.fr.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.fr.xlf
index 3f30c43afdf..e76dd0fc68a 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.fr.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.fr.xlf
@@ -7,6 +7,11 @@
Fichier .runsettings non valide, « <RunSettings> » attribut est manquantDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileChemin d’accès, relatif ou absolu, au fichier .runsettings. Pour plus d’informations et d’exemples sur la configuration de la série de tests, consultez https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.it.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.it.xlf
index df9d3f00b78..951b6d70544 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.it.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.it.xlf
@@ -7,6 +7,11 @@
File .runsettings non valido. Attributo '<RunSettings>' mancanteDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-filePercorso, relativo o assoluto, del file .runsettings. Per altre informazioni ed esempi su come configurare l'esecuzione dei test, vedere https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ja.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ja.xlf
index d646cf83a7a..8690395fd48 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ja.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ja.xlf
@@ -7,6 +7,11 @@
.runsettings ファイルが無効です。'<RunSettings>' 属性がありませんDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings ファイルへの相対パスまたは絶対パス。テストの実行を構成する方法の詳細と例については、https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file を参照してください
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ko.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ko.xlf
index 8f18dcc42fa..dd7b342a542 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ko.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ko.xlf
@@ -7,6 +7,11 @@
.runsettings 파일이 잘못되었습니다. '<RunSettings>' 특성이 없습니다.Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings 파일에 대한 상대 또는 절대 경로입니다. 테스트 실행을 구성하는 방법에 관한 자세한 내용 및 예시는 https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file을 참조하세요.
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pl.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pl.xlf
index 6735a3a8b2d..70e99b5b06f 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pl.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pl.xlf
@@ -7,6 +7,11 @@
Nieprawidłowy plik .runsettings, brak atrybutu „<RunSettings>”Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileŚcieżka względna lub bezwzględna pliku .runsettings. Aby uzyskać więcej informacji i przykładów dotyczących konfigurowania przebiegu testu, zobacz: https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pt-BR.xlf
index f4e9e3d5624..4a506b985ef 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pt-BR.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.pt-BR.xlf
@@ -7,6 +7,11 @@
Arquivo .runsettings inválido, o atributo "<RunSettings>" está ausenteDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileO caminho, relativo ou absoluto, para o arquivo .runsettings. Para obter mais informações e exemplos sobre como configurar a execução de teste, consulte https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ru.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ru.xlf
index ef3dfdbb5b1..438536918af 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ru.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.ru.xlf
@@ -7,6 +7,11 @@
Недопустимый файл .runsettings, отсутствует атрибут "<RunSettings>"Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-fileОтносительный или абсолютный путь к файлу .runsettings. Дополнительные сведения и примеры настройки тестового запуска см. на странице https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.tr.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.tr.xlf
index ab5cd1fd2ed..3e4fa833bf0 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.tr.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.tr.xlf
@@ -7,6 +7,11 @@
Geçersiz .runsettings dosyası, '<RunSettings>' özniteliği eksikDo not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings dosyasının göreli veya mutlak yolu. Test çalıştırmasını yapılandırma hakkında daha fazla bilgi ve örnek için şu sayfaya bakın: https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hans.xlf
index 52c79461faf..0f2ae5071b5 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hans.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hans.xlf
@@ -7,6 +7,11 @@
.runsettings 文件无效,缺少 '<RunSettings>' 属性Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings 文件的相对路径或绝对路径。有关如何配置测试运行的详细信息和示例,请参阅 https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hant.xlf
index 2c8ee9509cf..4e003c60fd1 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hant.xlf
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Resources/xlf/ExtensionResources.zh-Hant.xlf
@@ -7,6 +7,11 @@
.runsettings 檔案無效,遺漏 '<RunSettings>' 屬性Do not localize file extension {Locked=".runsettings"} or element {Locked="<RunSettings>"}.
+
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ The runsettings 'EnvironmentVariables' section is not supported on browser/WebAssembly platforms, because applying it requires restarting the test host process. Remove the section to run on browser-wasm.
+ {Locked="runsettings"}{Locked="EnvironmentVariables"}{Locked="browser-wasm"}
+ The path, relative or absolute, to the .runsettings file. For more information and examples on how to configure test run, see https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file.runsettings 檔案的相對或絕對路徑。如需如何設定測試回合的詳細資訊和範例,請參閱 https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file#the-runsettings-file
diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/BrowserOutputDevice.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/BrowserOutputDevice.cs
index a0e37a1a788..98778eb1854 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/BrowserOutputDevice.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/BrowserOutputDevice.cs
@@ -33,7 +33,7 @@ public BrowserOutputDevice(
///
public override string Description => "Test Platform browser console service using JavaScript interop";
- [JSImport("globalThis.console.warn", "main.js")]
+ [JSImport("globalThis.console.warn")]
private static partial void JSConsoleWarn(string? message);
[JSImport("globalThis.console.error")]
diff --git a/src/Platform/SharedExtensionHelpers/RunSettingsCommandLineOptionsProviderBase.cs b/src/Platform/SharedExtensionHelpers/RunSettingsCommandLineOptionsProviderBase.cs
index a416721457c..7e9000b6181 100644
--- a/src/Platform/SharedExtensionHelpers/RunSettingsCommandLineOptionsProviderBase.cs
+++ b/src/Platform/SharedExtensionHelpers/RunSettingsCommandLineOptionsProviderBase.cs
@@ -37,6 +37,13 @@ protected RunSettingsCommandLineOptionsProviderBase(
_fileCannotBeReadErrorFormat = fileCannotBeReadErrorFormat;
}
+ ///
+ /// Gets the localized error surfaced when a browser/WebAssembly run supplies runsettings that declare an
+ /// <EnvironmentVariables> section. Concrete providers supply it from their own resources so the
+ /// diagnostic is localizable.
+ ///
+ protected abstract string EnvironmentVariablesNotSupportedOnBrowserError { get; }
+
///
public sealed override Task ValidateOptionArgumentsAsync(CommandLineOption commandOption, string[] arguments)
{
@@ -48,5 +55,35 @@ public sealed override Task ValidateOptionArgumentsAsync(Comma
? ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, _fileCannotBeReadErrorFormat, filePath))
: ValidationResult.ValidTask;
}
+
+ ///
+ public sealed override async Task ValidateCommandLineOptionsAsync(ICommandLineOptions commandLineOptions)
+ {
+ // On browser/WebAssembly, applying a runsettings section requires relaunching the
+ // test host with those variables set — a test-host-controller feature that needs a process restart, which
+ // the browser sandbox does not support (so the environment-variable provider is not registered there).
+ // Rather than silently ignoring the section (which would run the tests with different semantics than
+ // requested), fail with a clear unsupported-platform diagnostic. This validation runs regardless of how the
+ // runsettings were supplied — the --settings option OR the TESTINGPLATFORM_EXPERIMENTAL_VSTEST_RUNSETTINGS /
+ // TESTINGPLATFORM_VSTESTBRIDGE_RUNSETTINGS_FILE environment variables — because TryLoadRunSettingsAsync
+ // resolves all three sources. Guarded to NETCOREAPP because browser-wasm only runs there (and
+ // OperatingSystem.IsBrowser is a built-in since .NET 8, so no polyfill is needed). See
+ // https://github.com/microsoft/testfx/issues/2196.
+#if NETCOREAPP
+ if (OperatingSystem.IsBrowser())
+ {
+ XDocument? runSettings = await RunSettingsProviderHelper.TryLoadRunSettingsAsync(
+ commandLineOptions, _fileSystem, new SystemEnvironment(), RunSettingsOptionName).ConfigureAwait(false);
+ if (runSettings is not null && RunSettingsProviderHelper.HasEnvironmentVariables(runSettings))
+ {
+ return ValidationResult.Invalid(EnvironmentVariablesNotSupportedOnBrowserError);
+ }
+ }
+#else
+ await Task.CompletedTask.ConfigureAwait(false);
+#endif
+
+ return ValidationResult.Valid();
+ }
}
#endif
diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs
new file mode 100644
index 00000000000..569c4156052
--- /dev/null
+++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/BrowserWasmExecutionTests.cs
@@ -0,0 +1,524 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.Testing.Platform.Acceptance.IntegrationTests;
+
+///
+/// End-to-end coverage for running MSTest tests on browser-wasm (issue
+/// ).
+///
+///
+/// browser-wasm shares the single-threaded execution model of wasi-wasm (no thread
+/// pool: Task.Run continuations never execute and blocking waits throw
+/// ), and the same platform/adapter fallbacks
+/// (RuntimeFeatureHelper.IsMultiThreaded / RuntimeContext.IsMultiThreaded) already cover
+/// both. What differs is the host: wasi-wasm runs headless under wasmtime, while
+/// browser-wasm boots through a JS module that loads dotnet.js. Because
+/// Microsoft.Testing.Platform never touches the DOM, the published bundle boots headlessly under
+/// node via the same loader, which is what this test uses instead of a real browser.
+///
+///
+/// Three complementary assertions, mirroring :
+///
+///
+/// builds for
+/// browser-wasm and asserts the MTP entry point is generated. The repo bootstrap
+/// installs the required wasm-tools workload (see eng/restore-toolset), so this
+/// runs in CI; it is skipped (inconclusive) only when that workload is genuinely absent (e.g.
+/// a local machine that has not run the bootstrap), and otherwise a build failure fails the test.
+///
+///
+/// publishes a real MSTest project for
+/// browser-wasm and boots it end-to-end under node via a small
+/// dotnet.js runner, asserting the passing tests report success and the failing test is
+/// reported as failed. Skipped (inconclusive) only when the wasm-tools workload or
+/// node is unavailable; otherwise publish must succeed and the run must exit with
+/// AtLeastOneTestFailed.
+///
+///
+/// publishes a custom-framework
+/// project that emits a warning and an error through IOutputDevice, and asserts both reach
+/// the Node output via the [JSImport] console bindings without a JS-interop exception —
+/// directly guarding the BrowserOutputDevice.JSConsoleWarn fix. Same skip conditions.
+///
+///
+///
+[TestClass]
+public sealed class BrowserWasmExecutionTests : AcceptanceTestBase
+{
+ // browser-wasm is only supported on the current .NET TFM in this repo (see samples/BrowserPlayground).
+ private static readonly string TargetFramework = TargetFrameworks.NetCurrent;
+
+ // Minimal MSTest project targeting browser-wasm, running on Microsoft.Testing.Platform via the
+ // generated entry point. The bundled main.js is the WasmMainJSPath boot module (needed for a
+ // browser-wasm build to produce a bundle); the node run below uses a runner staged at test time.
+ // One passing and one failing test so the run exercises both the success summary and the
+ // non-zero exit code on failure.
+ private const string SourceCode = """
+#file BrowserTestProject.csproj
+
+
+
+ $TargetFramework$
+ $BrowserRid$
+ Exe
+
+ true
+ enable
+ enable
+ true
+
+
+ true
+
+
+ main.js
+
+
+ false
+ false
+
+ $(NoWarn);NETSDK1201
+
+
+
+
+
+
+
+
+#file main.js
+import { dotnet } from './_framework/dotnet.js';
+const { runMain } = await dotnet.withApplicationArgumentsFromQuery().create();
+const exitCode = await runMain();
+globalThis.mtpExitCode = exitCode;
+
+#file UnitTest1.cs
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+[TestClass]
+public sealed class UnitTest1
+{
+ [TestMethod]
+ public void PassingTest()
+ => Assert.AreEqual(4, 2 + 2);
+
+ [TestMethod]
+ public void AnotherPassingTest()
+ => Assert.IsTrue(true);
+
+ [TestMethod]
+ public void FailingTest()
+ => Assert.Fail("Intentional failure to verify failures are reported under browser-wasm.");
+}
+""";
+
+ // node runner staged next to the published bundle. Boots the browser-wasm app under node (no DOM
+ // required — Microsoft.Testing.Platform does not touch the DOM) and maps the .NET exit code onto
+ // the node process exit code. Mirrors samples/BrowserPlayground/wwwroot/runtests.mjs.
+ private const string NodeRunnerSource = """
+import { dotnet } from './_framework/dotnet.js';
+const { runMain } = await dotnet.withApplicationArguments(...process.argv.slice(2)).create();
+const exitCode = await runMain();
+// Set exitCode rather than calling process.exit(): process.exit() can terminate Node before
+// redirected stdout/stderr has flushed, which would truncate the MTP summary this test asserts on.
+process.exitCode = exitCode;
+""";
+
+ // The runsettings XML (declaring an section) that the run-settings validation
+ // test supplies to the browser-wasm host. It is passed as *content* via the
+ // TESTINGPLATFORM_EXPERIMENTAL_VSTEST_RUNSETTINGS environment variable rather than as a file, so the
+ // test does not depend on the wasm virtual-filesystem resolving a --settings file path.
+ private const string RunSettingsWithEnvironmentVariablesXml =
+ "1";
+
+ // Node runner that supplies the above runsettings through the content runsettings environment variable
+ // (TESTINGPLATFORM_EXPERIMENTAL_VSTEST_RUNSETTINGS) via the dotnet.js host builder's
+ // withEnvironmentVariable API. This exercises the environment-variable runsettings resolution path (not
+ // just --settings), which flows through the same RunSettingsProviderHelper.TryLoadRunSettingsAsync used
+ // by RunSettingsCommandLineOptionsProviderBase.ValidateCommandLineOptionsAsync.
+ private const string NodeRunnerWithRunSettingsContentEnvVarSource = """
+import { dotnet } from './_framework/dotnet.js';
+const runSettings = '$RunSettingsXml$';
+const { runMain } = await dotnet
+ .withEnvironmentVariable('TESTINGPLATFORM_EXPERIMENTAL_VSTEST_RUNSETTINGS', runSettings)
+ .withApplicationArguments()
+ .create();
+const exitCode = await runMain();
+process.exitCode = exitCode;
+""";
+
+ // Minimal browser-wasm MSTest project with a single passing test. The runsettings
+ // are injected at runtime via the environment variable (see the runner above), so no runsettings file is
+ // bundled.
+ private const string RunSettingsSourceCode = """
+#file BrowserRunSettingsProject.csproj
+
+
+
+ $TargetFramework$
+ $BrowserRid$
+ Exe
+ true
+ enable
+ enable
+ true
+ true
+ main.js
+ false
+ false
+ $(NoWarn);NETSDK1201
+
+
+
+
+
+
+
+
+#file main.js
+import { dotnet } from './_framework/dotnet.js';
+const { runMain } = await dotnet.withApplicationArgumentsFromQuery().create();
+const exitCode = await runMain();
+globalThis.mtpExitCode = exitCode;
+
+#file UnitTest1.cs
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+[TestClass]
+public sealed class UnitTest1
+{
+ [TestMethod]
+ public void PassingTest()
+ => Assert.IsTrue(true);
+}
+""";
+
+ // Deterministic strings the warning asset emits and the test asserts reach Node output.
+ private const string WarningText = "browser-wasm framework warning marker";
+ private const string ErrorText = "browser-wasm framework error marker";
+
+ // A minimal custom-framework browser-wasm project (no MSTest) that emits a warning and an error
+ // through IOutputDevice, then reports a single passing test. Unlike the MSTest asset it hosts MTP
+ // via its own Program.Main (like samples/BrowserPlayground), so the warning path through
+ // BrowserOutputDevice.JSConsoleWarn is exercised end-to-end.
+ private const string WarningSourceCode = """
+#file BrowserWarningProject.csproj
+
+
+
+ $TargetFramework$
+ $BrowserRid$
+ Exe
+ true
+ enable
+ enable
+ true
+ main.js
+ false
+ false
+ $(NoWarn);NETSDK1201
+
+
+
+
+
+
+
+
+#file main.js
+import { dotnet } from './_framework/dotnet.js';
+const { runMain } = await dotnet.withApplicationArgumentsFromQuery().create();
+const exitCode = await runMain();
+globalThis.mtpExitCode = exitCode;
+
+#file Program.cs
+using Microsoft.Testing.Platform.Builder;
+using Microsoft.Testing.Platform.Capabilities.TestFramework;
+using Microsoft.Testing.Platform.Extensions.Messages;
+using Microsoft.Testing.Platform.Extensions.OutputDevice;
+using Microsoft.Testing.Platform.Extensions.TestFramework;
+using Microsoft.Testing.Platform.OutputDevice;
+using Microsoft.Testing.Platform.Services;
+
+ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args);
+builder.RegisterTestFramework(
+ _ => new TestFrameworkCapabilities(),
+ (_, serviceProvider) => new WarningFramework(serviceProvider.GetOutputDevice()));
+using ITestApplication app = await builder.BuildAsync();
+return await app.RunAsync();
+
+internal sealed class WarningFramework : ITestFramework, IDataProducer, IOutputDeviceDataProducer
+{
+ private readonly IOutputDevice _outputDevice;
+
+ public WarningFramework(IOutputDevice outputDevice) => _outputDevice = outputDevice;
+
+ public string Uid => nameof(WarningFramework);
+ public string Version => "1.0.0";
+ public string DisplayName => nameof(WarningFramework);
+ public string Description => nameof(WarningFramework);
+ public Type[] DataTypesProduced => [typeof(TestNodeUpdateMessage)];
+ public Task IsEnabledAsync() => Task.FromResult(true);
+ public Task CreateTestSessionAsync(CreateTestSessionContext context)
+ => Task.FromResult(new CreateTestSessionResult() { IsSuccess = true });
+ public Task CloseTestSessionAsync(CloseTestSessionContext context)
+ => Task.FromResult(new CloseTestSessionResult() { IsSuccess = true });
+
+ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
+ {
+ await _outputDevice.DisplayAsync(this, new WarningMessageOutputDeviceData("$WarningText$"), CancellationToken.None);
+ await _outputDevice.DisplayAsync(this, new ErrorMessageOutputDeviceData("$ErrorText$"), CancellationToken.None);
+ await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode()
+ {
+ DisplayName = "PassingNode",
+ Uid = "Uid1",
+ Properties = new PropertyBag(PassedTestNodeStateProperty.CachedInstance),
+ }));
+ context.Complete();
+ }
+}
+""";
+
+ public TestContext TestContext { get; set; } = null!;
+
+ [TestMethod]
+ public async Task BrowserWasmBuild_GeneratesTestingPlatformEntryPoint()
+ {
+ using TestAsset generator = await GenerateBrowserWasmAssetAsync();
+
+ // Only a missing 'wasm-tools' workload is an acceptable skip; any other build failure (compiler
+ // error, a broken generated MTP entry point) is a real regression and must fail the test.
+ DotnetMuxerResult buildResult = await DotnetCli.RunAsync(
+ $"build {generator.TargetAssetPath} -f {TargetFramework} -r {WasmRuntime.BrowserRid} -c Release",
+ // Trimming/wasm builds can emit non-actionable warnings; we only assert on the build
+ // succeeding and the entry point being generated, not on a warning-clean build.
+ warnAsError: false,
+ failIfReturnValueIsNotZero: false,
+ cancellationToken: TestContext.CancellationToken);
+
+ if (buildResult.ExitCode != 0)
+ {
+ Assert.IsTrue(
+ WasmRuntime.IsMissingWasmToolsWorkload(buildResult),
+ $"'dotnet build -r browser-wasm' failed for an unexpected reason (not a missing 'wasm-tools' workload).{Environment.NewLine}{buildResult}");
+ Assert.Inconclusive(
+ $"Skipping browser-wasm build: the 'wasm-tools' workload is not installed.{Environment.NewLine}{buildResult}");
+ return;
+ }
+
+ // The MTP MSBuild task writes the generated entry point into the intermediate output folder.
+ // Its presence proves the browser-wasm build produced the Microsoft.Testing.Platform host
+ // entry point (the plumbing that browser-wasm execution ultimately relies on).
+ string[] generatedEntryPoints = Directory.GetFiles(
+ Path.Combine(generator.TargetAssetPath, "obj"),
+ "MicrosoftTestingPlatformEntryPoint.cs",
+ SearchOption.AllDirectories);
+
+ Assert.IsNotEmpty(
+ generatedEntryPoints,
+ $"Expected a generated 'MicrosoftTestingPlatformEntryPoint.cs' under '{Path.Combine(generator.TargetAssetPath, "obj")}'.");
+ }
+
+ [TestMethod]
+ public async Task BrowserWasmExecution_RunsTestsUnderNode()
+ {
+ // Gate the runtime invocation on 'node'; the publish step below handles the 'wasm-tools'
+ // workload skip. With the workload and node present, publish and execution must succeed as
+ // asserted, so browser-specific publish or run regressions are not silently swallowed.
+ string? node = WasmRuntime.LocateNode();
+ if (node is null)
+ {
+ Assert.Inconclusive(WasmRuntime.NodeUnavailableMessage);
+ return;
+ }
+
+ using TestAsset generator = await GenerateBrowserWasmAssetAsync();
+
+ (int exitCode, string output, string error, string combined) = await PublishAndRunUnderNodeAsync(generator, node);
+
+ // A PlatformNotSupportedException (the single-threaded blocking-wait failure mode) would
+ // indicate a regression in the wasm fallbacks.
+ Assert.IsFalse(
+ error.Contains("PlatformNotSupportedException", StringComparison.Ordinal)
+ || output.Contains("PlatformNotSupportedException", StringComparison.Ordinal),
+ $"Microsoft.Testing.Platform hit an unexpected PlatformNotSupportedException under browser-wasm.{Environment.NewLine}{combined}");
+
+ // The run summary proves tests actually executed: the two passing tests succeeded and the
+ // intentional failure was reported. Assert on the combined output: on browser-wasm the
+ // failed-run summary is routed through BrowserOutputDevice.ConsoleError -> console.error
+ // (stderr), unlike wasi where everything lands on stdout.
+ Assert.IsTrue(
+ combined.Contains("succeeded: 2", StringComparison.Ordinal),
+ $"Expected 2 succeeded tests in the browser-wasm run summary.{Environment.NewLine}{combined}");
+ Assert.IsTrue(
+ combined.Contains("failed: 1", StringComparison.Ordinal),
+ $"Expected 1 failed test in the browser-wasm run summary.{Environment.NewLine}{combined}");
+
+ // Assert the exact "at least one test failed" exit code (2). A generic non-zero check would
+ // also pass for a post-run crash or other MTP failure; requiring AtLeastOneTestFailed keeps
+ // those from masquerading as the expected failing-test outcome.
+ Assert.AreEqual(
+ (int)ExitCode.AtLeastOneTestFailed,
+ exitCode,
+ $"Expected exit code {(int)ExitCode.AtLeastOneTestFailed} (AtLeastOneTestFailed) because one test fails.{Environment.NewLine}{combined}");
+ }
+
+ [TestMethod]
+ public async Task BrowserWasmExecution_FrameworkWarningReachesNode()
+ {
+ // Guards the BrowserOutputDevice.JSConsoleWarn binding fix: the other execution test never
+ // emits a WarningMessageOutputDeviceData, so it would still pass if the console.warn interop
+ // were broken. Here a custom framework emits a deterministic warning (and error) that must
+ // reach the Node output via [JSImport] without a JS interop / PlatformNotSupportedException.
+ string? node = WasmRuntime.LocateNode();
+ if (node is null)
+ {
+ Assert.Inconclusive(WasmRuntime.NodeUnavailableMessage);
+ return;
+ }
+
+ using TestAsset generator = await GenerateBrowserWasmWarningAssetAsync();
+
+ (int exitCode, string output, string error, string combined) = await PublishAndRunUnderNodeAsync(generator, node);
+
+ // The warning routes through BrowserOutputDevice.ConsoleWarn -> JSConsoleWarn ->
+ // globalThis.console.warn (stderr under Node); the error routes through console.error. Both
+ // going through the wasm JS interop must not throw, and the text must actually surface.
+ Assert.IsFalse(
+ error.Contains("PlatformNotSupportedException", StringComparison.Ordinal)
+ || output.Contains("PlatformNotSupportedException", StringComparison.Ordinal),
+ $"Microsoft.Testing.Platform hit an unexpected PlatformNotSupportedException under browser-wasm.{Environment.NewLine}{combined}");
+
+ Assert.IsTrue(
+ combined.Contains(WarningText, StringComparison.Ordinal),
+ $"Expected the framework warning to reach the Node output via console.warn interop.{Environment.NewLine}{combined}");
+ Assert.IsTrue(
+ combined.Contains(ErrorText, StringComparison.Ordinal),
+ $"Expected the framework error to reach the Node output via console.error interop.{Environment.NewLine}{combined}");
+
+ // The framework reports a single passing test and no failures, so the run succeeds.
+ Assert.AreEqual(
+ (int)ExitCode.Success,
+ exitCode,
+ $"Expected exit code {(int)ExitCode.Success} (Success) for the warning asset.{Environment.NewLine}{combined}");
+ }
+
+ [TestMethod]
+ public async Task BrowserWasmExecution_RunSettingsEnvironmentVariables_FailsWithClearDiagnostic()
+ {
+ // Guards RunSettingsCommandLineOptionsProviderBase.ValidateCommandLineOptionsAsync: a runsettings
+ // section can't be applied on browser (it needs a test-host-controller
+ // process restart), so the run must fail with the localized diagnostic rather than silently
+ // ignoring the variables. The runsettings are supplied through the content environment variable
+ // (TESTINGPLATFORM_EXPERIMENTAL_VSTEST_RUNSETTINGS), which flows through the same
+ // RunSettingsProviderHelper.TryLoadRunSettingsAsync resolution the validation uses — so it also
+ // covers the environment-variable resolution path, not only --settings.
+ string? node = WasmRuntime.LocateNode();
+ if (node is null)
+ {
+ Assert.Inconclusive(WasmRuntime.NodeUnavailableMessage);
+ return;
+ }
+
+ using TestAsset generator = await GenerateBrowserWasmRunSettingsAssetAsync();
+
+ DotnetMuxerResult publishResult = await WasmRuntime.PublishForBrowserAsync(
+ generator.TargetAssetPath, TargetFramework, TestContext.CancellationToken);
+ if (publishResult.ExitCode != 0)
+ {
+ Assert.IsTrue(
+ WasmRuntime.IsMissingWasmToolsWorkload(publishResult),
+ $"'dotnet publish -r browser-wasm' failed for an unexpected reason (not a missing 'wasm-tools' workload).{Environment.NewLine}{publishResult}");
+ Assert.Inconclusive(
+ $"Skipping browser-wasm execution: the 'wasm-tools' workload is not installed.{Environment.NewLine}{publishResult}");
+ }
+
+ string appBundle = WasmRuntime.GetBrowserAppBundlePath(generator.TargetAssetPath, TargetFramework);
+ Assert.IsTrue(
+ Directory.Exists(appBundle),
+ $"Expected the browser-wasm AppBundle directory at '{appBundle}'.");
+
+ string runner = NodeRunnerWithRunSettingsContentEnvVarSource.PatchCodeWithReplace("$RunSettingsXml$", RunSettingsWithEnvironmentVariablesXml);
+ (int exitCode, _, _, string combined) = await WasmRuntime.RunUnderNodeAsync(
+ node, appBundle, runner, TestContext.CancellationToken);
+
+ // A PlatformNotSupportedException would mean the section slipped past validation into the
+ // controller registration path (the regression this diagnostic replaces).
+ Assert.IsFalse(
+ combined.Contains("PlatformNotSupportedException", StringComparison.Ordinal),
+ $"Expected a clean command-line validation failure, not a PlatformNotSupportedException.{Environment.NewLine}{combined}");
+
+ // The localized diagnostic is surfaced (matched on the stable, non-localized substrings).
+ Assert.IsTrue(
+ combined.Contains("EnvironmentVariables", StringComparison.Ordinal)
+ && combined.Contains("browser", StringComparison.OrdinalIgnoreCase),
+ $"Expected the browser unsupported diagnostic in the output.{Environment.NewLine}{combined}");
+
+ // Command-line validation failures exit with InvalidCommandLine (5); the run is rejected before any
+ // test executes.
+ Assert.AreEqual(
+ (int)ExitCode.InvalidCommandLine,
+ exitCode,
+ $"Expected exit code {(int)ExitCode.InvalidCommandLine} (InvalidCommandLine).{Environment.NewLine}{combined}");
+ }
+
+ // Publishes the generated browser-wasm asset, staging + booting it under Node. Only a missing
+ // 'wasm-tools' workload is an acceptable skip (Inconclusive); any other publish failure is a real
+ // regression and fails the test. Returns the process exit code plus captured stdout/stderr.
+ private async Task<(int ExitCode, string Output, string Error, string Combined)> PublishAndRunUnderNodeAsync(TestAsset generator, string node)
+ {
+ DotnetMuxerResult publishResult = await WasmRuntime.PublishForBrowserAsync(
+ generator.TargetAssetPath, TargetFramework, TestContext.CancellationToken);
+ if (publishResult.ExitCode != 0)
+ {
+ Assert.IsTrue(
+ WasmRuntime.IsMissingWasmToolsWorkload(publishResult),
+ $"'dotnet publish -r browser-wasm' failed for an unexpected reason (not a missing 'wasm-tools' workload).{Environment.NewLine}{publishResult}");
+ Assert.Inconclusive(
+ $"Skipping browser-wasm execution: the 'wasm-tools' workload is not installed.{Environment.NewLine}{publishResult}");
+ }
+
+ string appBundle = WasmRuntime.GetBrowserAppBundlePath(generator.TargetAssetPath, TargetFramework);
+ Assert.IsTrue(
+ Directory.Exists(appBundle),
+ $"Expected the browser-wasm AppBundle directory at '{appBundle}'.");
+
+ return await WasmRuntime.RunUnderNodeAsync(node, appBundle, NodeRunnerSource, TestContext.CancellationToken);
+ }
+
+ private Task GenerateBrowserWasmAssetAsync()
+ => TestAsset.GenerateAssetAsync(
+ "BrowserTestProject",
+ SourceCode
+ .PatchCodeWithReplace("$TargetFramework$", TargetFramework)
+ .PatchCodeWithReplace("$BrowserRid$", WasmRuntime.BrowserRid)
+ .PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
+
+ private Task GenerateBrowserWasmWarningAssetAsync()
+ => TestAsset.GenerateAssetAsync(
+ "BrowserWarningProject",
+ WarningSourceCode
+ .PatchCodeWithReplace("$TargetFramework$", TargetFramework)
+ .PatchCodeWithReplace("$BrowserRid$", WasmRuntime.BrowserRid)
+ .PatchCodeWithReplace("$WarningText$", WarningText)
+ .PatchCodeWithReplace("$ErrorText$", ErrorText)
+ .PatchCodeWithReplace("$MicrosoftTestingPlatformVersion$", MicrosoftTestingPlatformVersion));
+
+ private Task GenerateBrowserWasmRunSettingsAssetAsync()
+ => TestAsset.GenerateAssetAsync(
+ "BrowserRunSettingsProject",
+ RunSettingsSourceCode
+ .PatchCodeWithReplace("$TargetFramework$", TargetFramework)
+ .PatchCodeWithReplace("$BrowserRid$", WasmRuntime.BrowserRid)
+ .PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
+}
diff --git a/test/Utilities/Microsoft.Testing.TestInfrastructure/WasmRuntime.cs b/test/Utilities/Microsoft.Testing.TestInfrastructure/WasmRuntime.cs
index 9b32b6d67d8..081c4542675 100644
--- a/test/Utilities/Microsoft.Testing.TestInfrastructure/WasmRuntime.cs
+++ b/test/Utilities/Microsoft.Testing.TestInfrastructure/WasmRuntime.cs
@@ -4,10 +4,22 @@
namespace Microsoft.Testing.TestInfrastructure;
///
-/// Shared helpers for the wasi-wasm acceptance tests (both the raw Microsoft.Testing.Platform
-/// tests and the MSTest ones). Centralizes locating wasmtime, publishing an asset for
-/// wasi-wasm, staging the ICU data file, and invoking the produced bundle under
-/// wasmtime so the two acceptance projects don't duplicate the plumbing.
+/// Shared helpers for the WebAssembly acceptance tests. Centralizes the plumbing so the acceptance
+/// projects don't duplicate it, covering both wasm runtimes:
+///
+///
+/// wasi-wasm (raw Microsoft.Testing.Platform and MSTest tests): locating
+/// wasmtime, publishing for wasi-wasm, staging the ICU data file, and invoking the
+/// produced bundle under wasmtime.
+///
+///
+/// browser-wasm (BrowserWasmExecutionTests): locating node, publishing
+/// for browser-wasm, and booting the produced bundle headlessly under node via the
+/// dotnet.js loader.
+///
+///
+/// Shared across both: distinguishes a genuine build/publish
+/// regression from the expected "the wasm-tools workload is not installed" skip.
///
public static class WasmRuntime
{
@@ -16,6 +28,18 @@ public static class WasmRuntime
///
public const string WasiRid = "wasi-wasm";
+ ///
+ /// The wasm runtime identifier that the mono browser runtime pack targets.
+ ///
+ public const string BrowserRid = "browser-wasm";
+
+ ///
+ /// Message a test should surface (via an inconclusive result) when node is unavailable.
+ ///
+ public const string NodeUnavailableMessage =
+ "Skipping browser-wasm execution: 'node' was not found on PATH (nor via NODE_EXE). " +
+ "Install Node.js to exercise this test.";
+
///
/// Message a test should surface (via an inconclusive result) when wasmtime is unavailable.
///
@@ -147,4 +171,86 @@ public static void StageIcuData(string appBundle)
File.Copy(icu, Path.Combine(appBundle, "icudt.dat"), overwrite: true);
}
}
+
+ ///
+ /// Locates the node executable via the NODE_EXE environment variable or PATH.
+ /// Returns when it is not available so callers can mark the test inconclusive.
+ /// browser-wasm normally boots in a browser, but Microsoft.Testing.Platform never touches the DOM,
+ /// so the same bundle boots headlessly under node via the dotnet.js loader.
+ ///
+ public static string? LocateNode()
+ {
+ // Return absolute paths: RunUnderNodeAsync starts node with the AppBundle as its working
+ // directory, so a relative NODE_EXE / PATH entry validated against the current directory here
+ // would no longer resolve to the same file once launched from elsewhere.
+ if (Environment.GetEnvironmentVariable("NODE_EXE") is { Length: > 0 } fromEnv && File.Exists(fromEnv))
+ {
+ return Path.GetFullPath(fromEnv);
+ }
+
+ string exeName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "node.exe" : "node";
+ string? path = Environment.GetEnvironmentVariable("PATH");
+ if (path is null)
+ {
+ return null;
+ }
+
+ foreach (string directory in path.Split(Path.PathSeparator))
+ {
+ if (directory.Length == 0)
+ {
+ continue;
+ }
+
+ string candidate = Path.Combine(directory, exeName);
+ if (File.Exists(candidate))
+ {
+ return Path.GetFullPath(candidate);
+ }
+ }
+
+ return null;
+ }
+
+ ///
+ /// Publishes the asset at for browser-wasm. As with
+ /// , failures are not treated as errors so callers can inspect
+ /// the exit code — and — to decide between an inconclusive
+ /// skip and a real failure.
+ ///
+ public static Task PublishForBrowserAsync(string targetAssetPath, string targetFramework, CancellationToken cancellationToken)
+ => DotnetCli.RunAsync(
+ $"publish {targetAssetPath} -f {targetFramework} -r {BrowserRid} -c Release",
+ warnAsError: false,
+ failIfReturnValueIsNotZero: false,
+ cancellationToken: cancellationToken);
+
+ ///
+ /// Gets the path to the AppBundle directory produced by a browser-wasm Release publish.
+ ///
+ public static string GetBrowserAppBundlePath(string targetAssetPath, string targetFramework)
+ => Path.Combine(targetAssetPath, "bin", "Release", targetFramework, BrowserRid, "AppBundle");
+
+ ///
+ /// Stages as runtests.mjs next to the published bundle
+ /// (so it can import ./_framework/dotnet.js) and boots it under node, returning the
+ /// process exit code plus captured stdout/stderr. The runner sets process.exitCode rather
+ /// than calling process.exit() so Node drains redirected streams before exiting.
+ ///
+ public static async Task<(int ExitCode, string Output, string Error, string Combined)> RunUnderNodeAsync(
+ string node, string appBundle, string nodeRunnerSource, CancellationToken cancellationToken)
+ {
+ File.WriteAllText(Path.Combine(appBundle, "runtests.mjs"), nodeRunnerSource);
+
+ var commandLine = new CommandLine();
+ int exitCode = await commandLine.RunAsyncAndReturnExitCodeAsync(
+ $"\"{node}\" runtests.mjs",
+ workingDirectory: appBundle,
+ cancellationToken: cancellationToken);
+
+ string output = commandLine.StandardOutput;
+ string error = commandLine.ErrorOutput;
+ string combined = $"STDOUT:{Environment.NewLine}{output}{Environment.NewLine}STDERR:{Environment.NewLine}{error}";
+ return (exitCode, output, error, combined);
+ }
}