Skip to content

MTP: Allow test results to have separate display name while keeping the original info for TestNode.DisplayName#7590

Closed
Youssef1313 wants to merge 2 commits intomainfrom
dev/ygerges/displayname
Closed

MTP: Allow test results to have separate display name while keeping the original info for TestNode.DisplayName#7590
Youssef1313 wants to merge 2 commits intomainfrom
dev/ygerges/displayname

Conversation

@Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Mar 23, 2026

TODOs:

  • Add integration tests for TRX for a folded MSTest parameterized test, and assert proper test definition.
  • Revise TRX implementation for any places with DisplayName and confirm if it's the display name of the test result (TestNodeUpdateMessage) or if it's the display name of the test case.

Copilot AI review requested due to automatic review settings March 23, 2026 11:53
@Youssef1313 Youssef1313 marked this pull request as draft March 23, 2026 11:53
Copy link
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 updates Microsoft.Testing.Platform (MTP) messaging so a TestNodeUpdateMessage can carry a custom display name (e.g., from a TestResult) without overwriting the underlying TestNode.DisplayName produced from the original TestCase.

Changes:

  • Added a new TestNodeUpdateMessage public constructor overload that accepts an explicit displayName.
  • Updated VSTest bridge conversion to stop using TestResult.DisplayName to populate TestNode.DisplayName.
  • Updated VSTest bridge result publishing to pass TestResult.DisplayName into TestNodeUpdateMessage when available.

Reviewed changes

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

File Description
src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Unshipped.txt Declares the newly added public constructor overload.
src/Platform/Microsoft.Testing.Platform/Messages/TestNodeUpdateMessage.cs Introduces the new constructor overload and delegates the existing ctor to it.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/ObjectModelConverters.cs Keeps TestNode.DisplayName sourced from TestCase rather than TestResult.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/FrameworkHandlerAdapter.cs Publishes TestNodeUpdateMessage with TestResult.DisplayName when recording results.

Comment on lines 12 to +13
/// <param name="testNode">The test node.</param>
/// <param name="displayName">The display name for the test update.</param>
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The XML doc tags for the primary constructor are out of order vs the actual parameter list (constructor is sessionUid, displayName, testNode, parentTestNodeUid, but docs list testNode before displayName). This can confuse generated docs/intellisense; please reorder the tags to match the signature and keep the parameter descriptions aligned with the correct parameters.

Suggested change
/// <param name="testNode">The test node.</param>
/// <param name="displayName">The display name for the test update.</param>
/// <param name="displayName">The display name for the test update.</param>
/// <param name="testNode">The test node.</param>

Copilot uses AI. Check for mistakes.
Comment on lines 122 to 136
/// <summary>
/// Converts a VSTest <see cref="TestResult"/> to a Microsoft Testing Platform <see cref="TestNode"/>.
/// </summary>
public static TestNode ToTestNode(
this TestResult testResult,
bool isTrxEnabled,
bool useFullyQualifiedNameAsUid,
Action<TestNode, TestCase> addAdditionalProperties,
INamedFeatureCapability? namedFeatureCapability,
ICommandLineOptions commandLineOptions,
IClientInfo clientInfo)
{
var testNode = testResult.TestCase.ToTestNode(isTrxEnabled, useFullyQualifiedNameAsUid, addAdditionalProperties, namedFeatureCapability, commandLineOptions, clientInfo, testResult.DisplayName);
var testNode = testResult.TestCase.ToTestNode(isTrxEnabled, useFullyQualifiedNameAsUid, addAdditionalProperties, namedFeatureCapability, commandLineOptions, clientInfo);

CopyCategoryAndTraits(testResult, testNode, isTrxEnabled);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

TestResult.DisplayName is no longer used to populate TestNode.DisplayName (now always using TestCase.DisplayName/FQN). There are existing unit tests for ObjectModelConverters, but none that assert this new behavior; please add/adjust a test to cover the scenario where TestResult.DisplayName differs from TestCase.DisplayName to prevent regressions.

Copilot uses AI. Check for mistakes.
@Youssef1313
Copy link
Member Author

After discussion with @Evangelink, we will address it differently and changes will be specific to TRX. I'll prepare another PR.

@Youssef1313 Youssef1313 deleted the dev/ygerges/displayname branch March 24, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants