Shorten data-driven test result names - #17303
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 20947b29-d6e7-4513-a3eb-063051d822f0
There was a problem hiding this comment.
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.FormatDisplayNamewith anisDataDrivenSubResultoption to return the framework display name for direct data-driven children. - Update
AzureDevOpsResultPublisherconversion logic to pass the data-driven-child flag only to direct children ofAggregationType.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
I'm not seeing this behavior in the code...can you point me to it? |
|
Yes—the PR only changes the direct children of a data-driven result.
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 20947b29-d6e7-4513-a3eb-063051d822f0
Summary
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