From e3c734c93ba787460477c698d4a79028d5181d6b Mon Sep 17 00:00:00 2001 From: Igor Velikorossov Date: Thu, 24 Apr 2025 14:23:04 +1000 Subject: [PATCH] Provide an injection point for custom test reporting functionality The current test logging implementation makes it difficult to know what tests failed during test execution. This especially affects GitHub Actions, which lack any test reporting functionality, and require developers to download logs and search for failures. The injection point provides the ability to mitigate the issue by allowing to inject a custom test reporter project before a test run is terminated (in an event of a failure). --- Documentation/ArcadeSdk.md | 51 +++++++++++++++++++ .../tools/VSTest.targets | 10 ++++ .../tools/XUnit/XUnit.Runner.targets | 10 ++++ .../tools/XUnitV3/XUnitV3.Runner.targets | 10 ++++ 4 files changed, 81 insertions(+) diff --git a/Documentation/ArcadeSdk.md b/Documentation/ArcadeSdk.md index 5ff86313be4..30f253310fa 100644 --- a/Documentation/ArcadeSdk.md +++ b/Documentation/ArcadeSdk.md @@ -1008,6 +1008,57 @@ Properties that define TargetFramework for use by projects so their targeting ea Set to `true` to indicate that the project is a test utility project. Such are projects that offer utilities to run tests. Example: `Microsoft.DotNet.XUnitExtensions.csproj` in Arcade. This makes are mark them as non-shipping and excluded from source build. +### `OnTestsExecutedProject` (string) + +The path to an MSBuild projects in the consumer repository with `OnTestsExecuted` target, that will be executed whenever project's test have been executed. This can be useful for custom test reporting functionality. + +For example: + +`tests/Directory.Build.props` in the consumer project: +```xml + + + + + $(OnTestsExecutedProperties);TestReporter=true + $(RepositoryEngineeringDir)TestReporter.proj + + +``` + +`eng/TestReporter.proj` in the consumer project: +```xml + + + + + + + + + + + + + + + +``` + +### `OnTestsExecutedProperties` (list of strings) + +List of custom properties to be passed to `OnTestsExecutedProject` whenever project's test have been executed. + ### `SkipTests` (bool) Set to `true` in a test project to skip running tests. diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/VSTest.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/VSTest.targets index fcc64fff4e7..ee45818e72e 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/VSTest.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/VSTest.targets @@ -70,6 +70,16 @@ <_ResultsFileToDisplay Condition="!Exists('$(_ResultsFileToDisplay)')">%(TestToRun.ResultsStdOutPath) + + + + + + +