Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
7 changes: 6 additions & 1 deletion .github/workflows/specialized-test-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ on:
required: false
type: boolean
default: false
# Extra arguments to pass to GenerateTestSummary tool
extraSummaryArgs:
required: false
type: string
description: 'Extra arguments to pass to GenerateTestSummary (e.g., --show-all-tests)'

jobs:

Expand Down Expand Up @@ -179,7 +184,7 @@ jobs:
--project ${{ github.workspace }}/tools/GenerateTestSummary/GenerateTestSummary.csproj
--
${{ github.workspace }}/testresults
--combined
${{ inputs.extraSummaryArgs || '--combined' }}
Copy link
Member

Choose a reason for hiding this comment

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

@copilot instead of this:

  1. let's add a new template parameter:
  • showOnlyFailedTestsInSummary defaulting to true
  • And if that is false then it should pass --show-all-tests as extraSummaryArgs to run-tests.yml
  • Also, if it is false then it we should be passing --show-all-tests in addition to --combined
  1. In the test summary generator support show-all-tests for the combined summary too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented as requested:

  1. Added showOnlyFailedTestsInSummary parameter (default true) to specialized-test-runner.yml
  2. When showOnlyFailedTestsInSummary is false, passes --show-all-tests along with --combined
  3. Updated CreateCombinedTestSummaryReport to accept showAllTests parameter and added GenerateAllTestsSection method
  4. Updated both workflows to use showOnlyFailedTestsInSummary: false

(e6d1420)


- name: Fail if any dependency failed
# 'skipped' can be when a transitive dependency fails and the dependent job gets 'skipped'.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests-outerloop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jobs:
extraRunSheetBuilderArgs: "-p:RunOuterloopTests=true"
extraTestArgs: "--filter-trait outerloop=true"
enablePlaywrightInstall: true
extraSummaryArgs: "--show-all-tests"
1 change: 1 addition & 0 deletions .github/workflows/tests-quarantine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ jobs:
extraTestArgs: "--filter-trait quarantined=true"
enablePlaywrightInstall: true
ignoreTestFailures: true
extraSummaryArgs: "--show-all-tests"
17 changes: 13 additions & 4 deletions tools/GenerateTestSummary/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
using System.CommandLine;
using Aspire.TestTools;

// Usage: dotnet tools run GenerateTestSummary --dirPathOrTrxFilePath <path> [--output <output>] [--combined]
// Usage: dotnet tools run GenerateTestSummary --dirPathOrTrxFilePath <path> [--output <output>] [--combined] [--show-all-tests]
// Generate a summary report from trx files.
// And write to $GITHUB_STEP_SUMMARY if running in GitHub Actions.

var dirPathOrTrxFilePathArgument = new Argument<string>("dirPathOrTrxFilePath");
var outputOption = new Option<string>("--output", "-o") { Description = "Output file path" };
var combinedSummaryOption = new Option<bool>("--combined", "-c") { Description = "Generate combined summary report" };
var urlOption = new Option<string>("--url", "-u") { Description = "URL for test links" };
var showAllTestsOption = new Option<bool>("--show-all-tests", "-a") { Description = "Show all tests (passing, failing, skipped) in a single list ordered by name" };

var rootCommand = new RootCommand
{
dirPathOrTrxFilePathArgument,
outputOption,
combinedSummaryOption,
urlOption
urlOption,
showAllTestsOption
};

rootCommand.SetAction(result =>
Expand All @@ -33,13 +35,20 @@

var combinedSummary = result.GetValue<bool>(combinedSummaryOption);
var url = result.GetValue<string>(urlOption);
var showAllTests = result.GetValue<bool>(showAllTestsOption);

if (combinedSummary && !string.IsNullOrEmpty(url))
{
Console.WriteLine("Error: --url option is not supported with --combined option.");
return;
}

if (showAllTests && combinedSummary)
{
Console.WriteLine("Error: --show-all-tests option is not supported with --combined option.");
return;
}

string report;
if (combinedSummary)
{
Expand All @@ -59,13 +68,13 @@
{
foreach (var trxFile in trxFiles)
{
TestSummaryGenerator.CreateSingleTestSummaryReport(trxFile, reportBuilder, url);
TestSummaryGenerator.CreateSingleTestSummaryReport(trxFile, reportBuilder, url, showAllTests);
}
}
}
else
{
TestSummaryGenerator.CreateSingleTestSummaryReport(dirPathOrTrxFilePath, reportBuilder, url);
TestSummaryGenerator.CreateSingleTestSummaryReport(dirPathOrTrxFilePath, reportBuilder, url, showAllTests);
}

report = reportBuilder.ToString();
Expand Down
34 changes: 28 additions & 6 deletions tools/GenerateTestSummary/TestSummaryGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static string CreateCombinedTestSummaryReport(string basePath)
return overallTableBuilder.ToString();
}

public static void CreateSingleTestSummaryReport(string trxFilePath, StringBuilder reportBuilder, string? url)
public static void CreateSingleTestSummaryReport(string trxFilePath, StringBuilder reportBuilder, string? url, bool showAllTests = false)
{
if (!File.Exists(trxFilePath))
{
Expand All @@ -222,7 +222,9 @@ public static void CreateSingleTestSummaryReport(string trxFilePath, StringBuild

var counters = testRun.ResultSummary.Counters;
var failed = counters.Failed;
if (failed == 0)

// Skip if no failed tests and we're only showing failed tests
if (failed == 0 && !showAllTests)
{
Console.WriteLine($"No failed tests in {trxFilePath}");
return;
Expand All @@ -248,14 +250,19 @@ public static void CreateSingleTestSummaryReport(string trxFilePath, StringBuild
return;
}

var failedTests = testRun.Results.UnitTestResults.Where(r => r.Outcome == "Failed");
if (failedTests.Any())
// Get tests to display - all tests if showAllTests, otherwise only failed
var testsToDisplay = showAllTests
? testRun.Results.UnitTestResults.OrderBy(r => r.TestName, StringComparer.OrdinalIgnoreCase)
: testRun.Results.UnitTestResults.Where(r => r.Outcome == "Failed");

foreach (var test in testsToDisplay)
{
foreach (var test in failedTests)
if (test.Outcome == "Failed")
{
// Failed tests get expanded details
reportBuilder.AppendLine("<div>");
reportBuilder.AppendLine(CultureInfo.InvariantCulture, $"""
<details><summary>🔴 <b>{test.TestName}</b></summary>
<details><summary> <b>{test.TestName}</b></summary>

""");

Expand Down Expand Up @@ -286,7 +293,22 @@ public static void CreateSingleTestSummaryReport(string trxFilePath, StringBuild

reportBuilder.AppendLine("```");
reportBuilder.AppendLine();
reportBuilder.AppendLine("</details>");
reportBuilder.AppendLine("</div>");
reportBuilder.AppendLine();
}
else if (showAllTests)
{
// Only show passing/skipped tests when showAllTests is true
if (test.Outcome == "Passed")
{
reportBuilder.AppendLine(CultureInfo.InvariantCulture, $"- ✅ {test.TestName}");
}
else
{
// Skipped/NotExecuted tests
reportBuilder.AppendLine(CultureInfo.InvariantCulture, $"- ⏭️ {test.TestName}");
}
}
}
reportBuilder.AppendLine();
Expand Down
Loading