Skip to content

Fix TRX result attachment layout to include per-test relative results directory#8188

Merged
Evangelink merged 3 commits into
mainfrom
copilot/fix-incorrect-result-file-paths
May 14, 2026
Merged

Fix TRX result attachment layout to include per-test relative results directory#8188
Evangelink merged 3 commits into
mainfrom
copilot/fix-incorrect-result-file-paths

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

Bug Fix

What was the bug?

With --report-trx --results-directory TestResults, per-test artifacts were copied to .../In/<machine>/... while TRX consumers resolved attachments via .../In/<relativeResultsDirectory>/<machine>/.... This mismatch caused attachment open failures locally and dropped attachments in Azure DevOps publishing.

How did you fix it?

  • Align per-test artifact copy path with TRX resolution semantics
    • Updated TrxReportEngine to route per-test artifact copies under:
      • <resultsDirectory>/<runDeploymentRoot>/In/<executionId>/<machineName>/...
    • executionId is already emitted as relativeResultsDirectory, so physical layout now matches downstream lookup behavior.
  • Keep existing href behavior unchanged
    • ResultFile path remains machine-relative (<machineName>/<fileName>), preserving current TRX payload shape.
  • Add focused regression coverage
    • Extended the existing TRX unit test to assert copy destination includes the relativeResultsDirectory segment.
string directoryName = relativeResultsDirectory is null
    ? Path.Combine(_configuration.GetTestResultDirectory(), runDeploymentRoot, "In", _environment.MachineName)
    : Path.Combine(_configuration.GetTestResultDirectory(), runDeploymentRoot, "In", relativeResultsDirectory, _environment.MachineName);

// per-test artifacts now pass executionId as relativeResultsDirectory
string href = CopyArtifactIntoTrxDirectoryAndReturnHrefValue(testFileArtifact.FileInfo, runDeploymentRoot, executionId);

Testing

Added/updated unit coverage in TrxTests to verify that per-test artifact copy paths include:
.../In/<relativeResultsDirectory>/MachineName/fileName.

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 13, 2026 16:37
Copilot AI changed the title [WIP] Fix incorrect paths to result files after merge Fix TRX result attachment layout to include per-test relative results directory May 13, 2026
Copilot AI requested a review from Evangelink May 13, 2026 16:38
@Evangelink Evangelink marked this pull request as ready for review May 14, 2026 07:40
Copilot AI review requested due to automatic review settings May 14, 2026 07:40
@Evangelink
Copy link
Copy Markdown
Member

@copilot please add an acceptance test too

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 fixes a TRX attachment layout mismatch where per-test artifacts were being copied to .../In/<machine>/... while TRX consumers resolve them via .../In/<relativeResultsDirectory>/<machine>/..., causing attachment resolution failures (including Azure DevOps publishing).

Changes:

  • Updated TrxReportEngine to copy per-test ResultFile artifacts under runDeploymentRoot/In/<relativeResultsDirectory>/<machine>/... by passing executionId (emitted as relativeResultsDirectory) into the copy-path computation.
  • Kept TRX ResultFile path values machine-relative (<machine>/<file>), preserving existing TRX payload shape.
  • Extended the existing TRX unit test to assert that the copy destination includes the relativeResultsDirectory segment.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs Routes per-test artifact copy destinations under In/<relativeResultsDirectory>/<machine> while keeping href machine-relative.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxTests.cs Adds regression assertion verifying the per-test artifact copy destination includes relativeResultsDirectory.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 14, 2026

@copilot please add an acceptance test too

Added an acceptance test in TrxTests to cover this scenario (commit 719c704). It validates that with --report-trx + --results-directory, per-test artifacts are copied under In/<relativeResultsDirectory>/<machine>/... and not the legacy path.

@Evangelink
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Expert Code Review (command) failed. Please review the logs for details.

@Evangelink Evangelink enabled auto-merge (squash) May 14, 2026 12:34
@Evangelink Evangelink disabled auto-merge May 14, 2026 12:48
@Evangelink Evangelink merged commit 8ba4ab7 into main May 14, 2026
10 checks passed
@Evangelink Evangelink deleted the copilot/fix-incorrect-result-file-paths branch May 14, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants