Skip to content

Add TRX report support to Microsoft.Android.Run#11415

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/reimagined-barnacle
May 20, 2026
Merged

Add TRX report support to Microsoft.Android.Run#11415
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/reimagined-barnacle

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Description

Add TRX report support to Microsoft.Android.Run, the host-side MTP test adapter for Android dotnet test. This enables --report-trx to produce standard TRX result files.

Changes

  • Microsoft.Android.Run.csproj: Add Microsoft.Testing.Extensions.TrxReport package reference
  • Program.cs: Register TRX report provider via AddTrxReportProvider() in the MTP builder pipeline
  • AndroidTestAdapter.cs:
    • Add TrxFullyQualifiedTypeNameProperty and TrxExceptionProperty to test nodes for TRX report generation
    • Parse ClassName and StackTrace as separate fields from the TRX XML (previously concatenated into ErrorMessage)
    • Add AndroidTrxReportCapability implementing ITrxReportCapability
    • Register the capability in AndroidTestCapabilities
  • Microsoft.Android.Sdk.proj: Ship Microsoft.Testing.Extensions.TrxReport.dll and Microsoft.Testing.Extensions.TrxReport.Abstractions.dll in the SDK workload pack

Add Microsoft.Testing.Extensions.TrxReport to the Android test adapter,
enabling `--report-trx` support when running tests via `dotnet test`.

Changes:
- Add TrxReport package reference to the project
- Register TRX report provider in the MTP builder
- Add TRX report properties (TrxFullyQualifiedTypeNameProperty,
  TrxExceptionProperty) to test nodes
- Parse ClassName and StackTrace as separate fields from TRX XML
- Add AndroidTrxReportCapability implementing ITrxReportCapability
- Ship TrxReport DLLs in the SDK workload pack

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 20:21
Add "test-trx" test cases for MonoVM and CoreCLR that pass --report-trx
to dotnet test and verify a valid TRX file is produced with a
ResultSummary element.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds TRX report generation support to Microsoft.Android.Run (the host-side Microsoft Testing Platform adapter used for Android dotnet test), enabling --report-trx to emit standard TRX result files.

Changes:

  • Add the Microsoft.Testing.Extensions.TrxReport dependency and register AddTrxReportProvider() in the MTP builder pipeline.
  • Extend AndroidTestAdapter to surface TRX-required properties/capabilities and to parse TRX error message vs. stack trace as separate fields.
  • Include TRX report assemblies in the Microsoft.Android.Sdk.$(HostOS) workload pack.

Reviewed changes

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

File Description
src/Microsoft.Android.Run/Program.cs Registers the TRX report provider in the dotnet test MTP pipeline.
src/Microsoft.Android.Run/Microsoft.Android.Run.csproj Adds the TRX report package reference alongside Microsoft Testing Platform.
src/Microsoft.Android.Run/AndroidTestAdapter.cs Adds TRX properties/capability and adjusts TRX parsing to keep stack traces separate.
build-tools/create-packs/Microsoft.Android.Sdk.proj Ships TRX report assemblies in the SDK pack so the tool can run from the workload.

Comment thread src/Microsoft.Android.Run/AndroidTestAdapter.cs
Comment thread src/Microsoft.Android.Run/AndroidTestAdapter.cs
jonathanpeppers and others added 6 commits May 19, 2026 15:29
Instead of a separate test-trx mode, always pass --report-trx when
running dotnet test and assert the TRX file is produced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The TRX file is written relative to the Microsoft.Android.Run process
working directory (the SDK tools folder), not the project directory.
Parse the path from the "In process file artifacts produced" output
instead of searching the project directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MTP defaults its working directory to the DLL location (SDK tools
directory) rather than Environment.CurrentDirectory. This caused TRX
reports from --report-trx to be written to <sdk>/tools/TestResults/
instead of <project>/TestResults/.

Fix by passing --results-directory explicitly to MTP, using
Environment.CurrentDirectory which dotnet test sets to the project
directory via RunWorkingDirectory.

Also revert the regex-based TRX path parsing workaround in the test,
restoring the simpler approach of searching the project directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Include stack trace in FailedTestNodeStateProperty message so
  non-TRX consumers (console output, test node messages) still see
  the full failure details.
- Only add TrxExceptionProperty when at least one of ErrorMessage or
  StackTrace is present, avoiding empty exception entries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
Copy link
Copy Markdown
Member Author

/review

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

Android PR Reviewer completed successfully!

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ LGTM — Clean, well-structured addition

Summary: Adds TRX report support to Microsoft.Android.Run by integrating the Microsoft.Testing.Extensions.TrxReport package. The implementation correctly separates error messages from stack traces (previously concatenated), adds the required ITrxReportCapability implementation, and ships the new DLLs in the SDK pack.

What I liked:

  • Good separation of ErrorMessage and StackTrace into distinct TrxTestResult fields — this is a proper data model fix, not just bolting TRX on top
  • The --results-directory fallback logic is well-motivated (MTP defaulting to the DLL location is a real footgun) with a clear comment
  • Test coverage validates both TRX file existence and structural correctness
  • The AndroidTrxReportCapability no-op Enable() is the right pattern since properties are unconditionally attached

CI: Both public checks (CLA, dotnet-android AZDO build) are ✅.

Severity Count
💡 Suggestion 2

Two minor suggestions — one about the IsNullOrEmpty() extension method convention (pre-existing in the file, so deferred to a broader cleanup), and one about deeper TRX content assertions in the test.

Generated by Android PR Reviewer for issue #11415 · ● 3.6M

@simonrozsival simonrozsival merged commit 991f251 into main May 20, 2026
3 checks passed
@simonrozsival simonrozsival deleted the jonathanpeppers/reimagined-barnacle branch May 20, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants