Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,16 @@ private SummaryCounts AddResults(TestNodeUpdateMessage[] testNodeUpdateMessages,

// NOTE: In VSTest, MSTestDiscoverer.TmiTestId property is preferred if present.
string id = guid.ToString();
string displayName = RemoveInvalidXmlChar(testNode.DisplayName)!;
string testNodeDisplayName = RemoveInvalidXmlChar(testNode.DisplayName)!;
string testResultDisplayName = RemoveInvalidXmlChar(nodeMessage.DisplayName)!;
string executionId = Guid.NewGuid().ToString();

// Results
var unitTestResult = new XElement(
"UnitTestResult",
new XAttribute("executionId", executionId),
new XAttribute("testId", id),
new XAttribute("testName", displayName),
new XAttribute("testName", testResultDisplayName),
new XAttribute("computerName", _environment.MachineName));

TimingProperty? timing = testNode.Properties.SingleOrDefault<TimingProperty>();
Expand Down Expand Up @@ -563,7 +564,7 @@ private SummaryCounts AddResults(TestNodeUpdateMessage[] testNodeUpdateMessages,
// Add the test method to the test definitions if it's not already there
if (uniqueTestDefinitionTestIds.Add(id))
{
XElement unitTest = CreateUnitTestElementForTestDefinition(displayName, testAppModule, id, testNode, executionId);
XElement unitTest = CreateUnitTestElementForTestDefinition(testNodeDisplayName, testAppModule, id, testNode, executionId);

var testMethod = new XElement(
"TestMethod",
Expand All @@ -574,13 +575,13 @@ private SummaryCounts AddResults(TestNodeUpdateMessage[] testNodeUpdateMessages,
(string className, string? testMethodName) = GetClassAndMethodName(testNode);
testMethod.SetAttributeValue("className", className);

// NOTE: Historically, MTP used to always use displayName here.
// While VSTest never uses displayName.
// The use of displayName here is very wrong.
// NOTE: Historically, MTP used to always use testNodeDisplayName here.
// While VSTest never uses testNodeDisplayName.
// The use of testNodeDisplayName here is very wrong.
// We keep it as a fallback if we cannot determine the testMethodName (when TestMethodIdentifierProperty isn't present).
// This will most likely be hit for NUnit.
// However, this is very wrong and we probably should fail if TestMethodIdentifierProperty isn't present.
testMethod.SetAttributeValue("name", testMethodName ?? displayName);
testMethod.SetAttributeValue("name", testMethodName ?? testNodeDisplayName);

unitTest.Add(testMethod);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void RecordResult(TestResult testResult)
// Publish node state change to Microsoft Testing Platform
var testNode = testResult.ToTestNode(_isTrxEnabled, _adapterExtensionBase.UseFullyQualifiedNameAsTestNodeUid, _adapterExtensionBase.AddAdditionalProperties, _namedFeatureCapability, _commandLineOptions, _clientInfo);

var testNodeChange = new TestNodeUpdateMessage(_session.SessionUid, testNode);
var testNodeChange = new TestNodeUpdateMessage(_session.SessionUid, testResult.DisplayName ?? testNode.DisplayName, testNode);
_messageBus.PublishAsync(_adapterExtensionBase, testNodeChange).Await();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ public static TestNode ToTestNode(
Action<TestNode, TestCase> addAdditionalProperties,
INamedFeatureCapability? namedFeatureCapability,
ICommandLineOptions commandLineOptions,
IClientInfo clientInfo,
string? displayNameFromTestResult = null)
IClientInfo clientInfo)
{
string testNodeUid = useFullyQualifiedNameAsUid ? testCase.FullyQualifiedName : testCase.Id.ToString();

TestNode testNode = new()
{
Uid = new TestNodeUid(testNodeUid),
DisplayName = displayNameFromTestResult ?? testCase.DisplayName ?? testCase.FullyQualifiedName,
DisplayName = testCase.DisplayName ?? testCase.FullyQualifiedName,
};

CopyCategoryAndTraits(testCase, testNode, isTrxEnabled);
Expand Down Expand Up @@ -132,7 +131,7 @@ public static TestNode ToTestNode(
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ namespace Microsoft.Testing.Platform.Extensions.Messages;
/// </summary>
/// <param name="sessionUid">The session UID.</param>
/// <param name="testNode">The test node.</param>
/// <param name="displayName">The display name for the test update.</param>
Comment on lines 12 to +13
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.
/// <param name="parentTestNodeUid">The test node parent UID.</param>
public sealed class TestNodeUpdateMessage(SessionUid sessionUid, TestNode testNode, TestNodeUid? parentTestNodeUid = null)
: DataWithSessionUid("TestNode update", "This data is used to report a TestNode state change.", sessionUid)
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public sealed class TestNodeUpdateMessage(SessionUid sessionUid, string displayName, TestNode testNode, TestNodeUid? parentTestNodeUid = null) :
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
DataWithSessionUid(displayName, "This data is used to report a TestNode state change.", sessionUid)
{
/// <summary>
/// Initializes a new instance of the <see cref="TestNodeUpdateMessage"/> class.
/// </summary>
/// <param name="sessionUid">The session UID.</param>
/// <param name="testNode">The test node.</param>
/// <param name="parentTestNodeUid">The test node parent UID.</param>
public TestNodeUpdateMessage(SessionUid sessionUid, TestNode testNode, TestNodeUid? parentTestNodeUid = null)
: this(sessionUid, testNode.DisplayName, testNode, parentTestNodeUid)
{
}

/// <summary>
/// Gets the test node.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*REMOVED*Microsoft.Testing.Platform.Extensions.TestHost.ITestHostApplicationLifetime.AfterRunAsync(int exitCode, System.Threading.CancellationToken cancellation) -> System.Threading.Tasks.Task!
*REMOVED*Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessLifetimeHandler.OnTestHostProcessExitedAsync(Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessInformation! testHostProcessInformation, System.Threading.CancellationToken cancellation) -> System.Threading.Tasks.Task!
*REMOVED*Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessLifetimeHandler.OnTestHostProcessStartedAsync(Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessInformation! testHostProcessInformation, System.Threading.CancellationToken cancellation) -> System.Threading.Tasks.Task!
Microsoft.Testing.Platform.Extensions.Messages.TestNodeUpdateMessage.TestNodeUpdateMessage(Microsoft.Testing.Platform.TestHost.SessionUid sessionUid, string! displayName, Microsoft.Testing.Platform.Extensions.Messages.TestNode! testNode, Microsoft.Testing.Platform.Extensions.Messages.TestNodeUid? parentTestNodeUid = null) -> void
Microsoft.Testing.Platform.Extensions.TestHost.ITestHostApplicationLifetime.AfterRunAsync(int exitCode, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessLifetimeHandler.OnTestHostProcessExitedAsync(Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessInformation! testHostProcessInformation, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessLifetimeHandler.OnTestHostProcessStartedAsync(Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostProcessInformation! testHostProcessInformation, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Expand Down
Loading