From 4b52631262ba370136bb1cb6d251a0b59cdf9de8 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 7 May 2026 16:01:36 -0500 Subject: [PATCH 1/2] [tests] Add TRX report support for dotnet test Add `--report-trx` to the `dotnet test` invocation in `DotNetNewAndroidTest` and assert the TRX file is generated with test results. Include `Microsoft.Testing.Extensions.TrxReport` DLLs in the SDK package so the TRX report provider is available at runtime by adding them to `FilesToPackage` in `Microsoft.Android.Sdk.proj`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../create-packs/Microsoft.Android.Sdk.proj | 2 ++ .../Tests/InstallAndRunTests.cs | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/build-tools/create-packs/Microsoft.Android.Sdk.proj b/build-tools/create-packs/Microsoft.Android.Sdk.proj index e9e8af48982..ea9becb0dce 100644 --- a/build-tools/create-packs/Microsoft.Android.Sdk.proj +++ b/build-tools/create-packs/Microsoft.Android.Sdk.proj @@ -75,6 +75,8 @@ core workload SDK packs imported by WorkloadManifest.targets. + + diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index f178cda5a5a..779d555e251 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -2273,10 +2273,12 @@ public void DotNetNewAndroidTest (string mode, AndroidRuntime runtime) Assert.IsTrue (dotnet.Build (target: "Install", parameters: buildParameters.ToArray ()), "`dotnet build -t:Install` should succeed"); // Run based on mode - var runParameters = buildParameters.Select (p => $"/p:{p}").ToArray (); + var runParameters = buildParameters.Select (p => $"/p:{p}").ToList (); + if (mode == "test") + runParameters.Add ("--report-trx"); using var process = mode == "run" - ? dotnet.StartRun (waitForExit: true, parameters: runParameters) - : dotnet.StartTest (parameters: runParameters); + ? dotnet.StartRun (waitForExit: true, parameters: runParameters.ToArray ()) + : dotnet.StartTest (parameters: runParameters.ToArray ()); var locker = new Lock (); var output = new StringBuilder (); @@ -2329,6 +2331,15 @@ public void DotNetNewAndroidTest (string mode, AndroidRuntime runtime) StringAssert.Contains ("succeeded: 1", outputText, $"Output should report 1 passed test. See {logPath} for details."); StringAssert.Contains ("failed: 1", outputText, $"Output should report 1 failed test. See {logPath} for details."); StringAssert.Contains ("skipped: 1", outputText, $"Output should report 1 skipped test. See {logPath} for details."); + + // Verify TRX report was generated via --report-trx + var testResultsDir = Path.Combine (projectDirectory, "TestResults"); + Assert.IsTrue (Directory.Exists (testResultsDir), $"TestResults directory should exist at {testResultsDir}"); + var trxFiles = Directory.GetFiles (testResultsDir, "*.trx", SearchOption.AllDirectories); + Assert.IsTrue (trxFiles.Length > 0, $"At least one .trx file should exist in {testResultsDir}"); + var trxContent = File.ReadAllText (trxFiles [0]); + TestContext.AddTestAttachment (trxFiles [0]); + StringAssert.Contains ("UnitTestResult", trxContent, $"TRX file should contain test results. See {trxFiles [0]}"); } } From feda10f1ffa0186e88a5679d4b8403d2897921f6 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 8 May 2026 08:24:09 -0500 Subject: [PATCH 2/2] [build] Remove TrxReport DLLs from FilesToPackage for now These DLLs are not produced by the Microsoft.Android.Run build, so packaging them causes NU5019 errors. The TRX report provider comes from the MSTest NuGet package in the test project itself. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build-tools/create-packs/Microsoft.Android.Sdk.proj | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-tools/create-packs/Microsoft.Android.Sdk.proj b/build-tools/create-packs/Microsoft.Android.Sdk.proj index ea9becb0dce..e9e8af48982 100644 --- a/build-tools/create-packs/Microsoft.Android.Sdk.proj +++ b/build-tools/create-packs/Microsoft.Android.Sdk.proj @@ -75,8 +75,6 @@ core workload SDK packs imported by WorkloadManifest.targets. - -