Add TRX report support to Microsoft.Android.Run#11415
Conversation
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>
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>
There was a problem hiding this comment.
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.TrxReportdependency and registerAddTrxReportProvider()in the MTP builder pipeline. - Extend
AndroidTestAdapterto 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. |
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>
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ 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
ErrorMessageandStackTraceinto distinctTrxTestResultfields — this is a proper data model fix, not just bolting TRX on top - The
--results-directoryfallback 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
AndroidTrxReportCapabilityno-opEnable()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
Description
Add TRX report support to
Microsoft.Android.Run, the host-side MTP test adapter for Androiddotnet test. This enables--report-trxto produce standard TRX result files.Changes
Microsoft.Android.Run.csproj: AddMicrosoft.Testing.Extensions.TrxReportpackage referenceProgram.cs: Register TRX report provider viaAddTrxReportProvider()in the MTP builder pipelineAndroidTestAdapter.cs:TrxFullyQualifiedTypeNamePropertyandTrxExceptionPropertyto test nodes for TRX report generationClassNameandStackTraceas separate fields from the TRX XML (previously concatenated intoErrorMessage)AndroidTrxReportCapabilityimplementingITrxReportCapabilityAndroidTestCapabilitiesMicrosoft.Android.Sdk.proj: ShipMicrosoft.Testing.Extensions.TrxReport.dllandMicrosoft.Testing.Extensions.TrxReport.Abstractions.dllin the SDK workload pack