Skip to content

Shorten data-driven test result names - #17303

Open
Evangelink wants to merge 3 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/shorten-mstest-data-names
Open

Shorten data-driven test result names#17303
Evangelink wants to merge 3 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/shorten-mstest-data-names

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

  • keep fully qualified names on top-level Azure DevOps test results
  • use the original framework display name for direct data-driven child rows
  • preserve existing fully qualified formatting for rerun attempts and legacy behavior

Testing

  • .\Build.cmd -configuration Release -test -projects "src\Microsoft.DotNet.Helix\Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests.csproj" -verbosity minimal

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 20947b29-d6e7-4513-a3eb-063051d822f0
Copilot AI lite review requested due to automatic review settings August 10, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refines how Azure DevOps test result names are formatted when UseFullyQualifiedTestName is enabled, keeping fully qualified names for top-level results while shortening the display names of direct data-driven child rows.

Changes:

  • Extend TestNameFormatter.FormatDisplayName with an isDataDrivenSubResult option to return the framework display name for direct data-driven children.
  • Update AzureDevOpsResultPublisher conversion logic to pass the data-driven-child flag only to direct children of AggregationType.DataDriven.
  • Add/extend unit tests to validate name formatting for data-driven child rows and rerun-attempt naming behavior.
Show a summary per file
File Description
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/TestNameFormatterTests.cs Adds tests for the new data-driven-subresult formatting behavior.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs Adds tests validating published AzDO titles/display names for data-driven rows and rerun attempts when using FQN mode.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/TestNameFormatter.cs Introduces the isDataDrivenSubResult formatting path and updates formatting rules documentation.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs Wires the data-driven-subresult formatting behavior into published sub-result name generation.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Suppressed comments (6)

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs:75

  • These reflection-based assertions can throw NullReferenceException if the property name changes, which makes failures harder to diagnose. Consider asserting the property exists via Assert.NotNull before accessing its value.
            Assert.Equal(
                dataRowName,
                dataRowResult.GetType().GetProperty("DisplayName").GetValue(dataRowResult));

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs:121

  • These reflection-based assertions can throw NullReferenceException if the property name changes, which makes failures harder to diagnose. Consider asserting the property exists via Assert.NotNull before accessing its value.
            Assert.Equal(
                dataRowName,
                publishedRow.GetType().GetProperty("DisplayName").GetValue(publishedRow));

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs:124

  • These reflection-based assertions can throw NullReferenceException if the property name changes, which makes failures harder to diagnose. Consider asserting the property exists via Assert.NotNull before accessing its value.
            Assert.Equal(
                $"{fullyQualifiedName} (Attempt #1 - {dataRowName})",
                publishedAttempt.GetType().GetProperty("DisplayName").GetValue(publishedAttempt));

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs:135

  • If the private method name/signature changes, convertResults can be null and the test will fail with a NullReferenceException. Using Assert.NotNull on GetMethod gives a clearer failure message.
            MethodInfo convertResults = typeof(AzureDevOpsResultPublisher).GetMethod(
                "ConvertResults",
                BindingFlags.Instance | BindingFlags.NonPublic);
            var convertedResults = Assert.IsAssignableFrom<IEnumerable>(
                convertResults.Invoke(publisher, new object[] { new[] { test }, new object() }));

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs:138

  • GetProperty("Converted") can return null if the internal shape changes, producing a NullReferenceException. Asserting the property exists yields a clearer test failure.
            return convertedResult.GetType().GetProperty("Converted").GetValue(convertedResult);

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs:144

  • GetProperty("SubResults") can return null if the internal shape changes, producing a NullReferenceException. Asserting the property exists yields a clearer test failure.
            var subResults = Assert.IsAssignableFrom<IEnumerable>(
                publishedResult.GetType().GetProperty("SubResults").GetValue(publishedResult));
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 20947b29-d6e7-4513-a3eb-063051d822f0
Copilot AI review requested due to automatic review settings August 10, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@mmitche

mmitche commented Aug 10, 2026

Copy link
Copy Markdown
Member

preserve existing fully qualified formatting for rerun attempts and legacy behavior

I'm not seeing this behavior in the code...can you point me to it?

@Evangelink

Copy link
Copy Markdown
Member Author

Yes—the PR only changes the direct children of a data-driven result.

  • Legacy mode is preserved by DisplayNameFor: when UseFullyQualifiedTestName is false, it returns result.Name without calling the FQN formatter.
  • Rerun attempts are preserved because isDataDrivenSubResult is recomputed from the immediate parent at each recursion level. A DataDriven parent passes true to its row, but that Rerun row passes false to its attempt children, so attempts still use the existing FQN formatting.

FullyQualifiedNames_DataDrivenRerunRowsOnlyShortenDirectChildren covers that exact tree: the row is FeaturesSupport("classlib"), while its attempt remains Ns.MyTests.FeaturesSupport (Attempt #1 - FeaturesSupport("classlib")).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 20947b29-d6e7-4513-a3eb-063051d822f0
Copilot AI review requested due to automatic review settings August 11, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

3 participants