Skip to content

Commit 3393a8a

Browse files
authored
[vs17.14] Add test summary always in terminal logger (#12852)
**Description** Running tests with dotnet test, users see inconsistent number of projects and tests reported in the view. This is a UI only issue, failing tests will still fail the build. It is still worth fixing the issue because it makes the runs show repeatable numbers of tests to the user. The terminal node can be null before we receive the finish message. This will cause that some summaries are not accounted for and will be missing in the final output. The node is null for this reason: #12819 That fix is not backported. **Customer Impact:** Multiple runs of the same test suite report different total counts of tests and projects. **Regression?** No, this was never working correctly since the beginning of test reporting in Terminal Logger. **Risk:** Low, it impacts UI only. Link the PR to the original issue and to the PR to main. PR to main is merged: #12801 Fixes microsoft/vstest#15307 No additional impact on packages or localization.
1 parent ee6457a commit 3393a8a

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
33
<Project>
44
<PropertyGroup>
5-
<VersionPrefix>17.14.36</VersionPrefix>
5+
<VersionPrefix>17.14.37</VersionPrefix>
66
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
77
<PackageValidationBaselineVersion>17.13.9</PackageValidationBaselineVersion>
88
<AssemblyVersion>15.1.0.0</AssemblyVersion>

src/Build/Logging/TerminalLogger/TerminalLogger.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -906,30 +906,38 @@ private void MessageRaised(object sender, BuildMessageEventArgs e)
906906

907907
if (hasProject && project!.IsTestProject)
908908
{
909-
var node = _nodes[NodeIndexForContext(buildEventContext)];
909+
TerminalNodeStatus? node = _nodes[NodeIndexForContext(buildEventContext)];
910910

911911
// Consumes test update messages produced by VSTest and MSTest runner.
912-
if (node != null && e is IExtendedBuildEventArgs extendedMessage)
912+
if (e is IExtendedBuildEventArgs extendedMessage)
913913
{
914914
switch (extendedMessage.ExtendedType)
915915
{
916916
case "TLTESTPASSED":
917917
{
918-
var indicator = extendedMessage.ExtendedMetadata!["localizedResult"]!;
919-
var displayName = extendedMessage.ExtendedMetadata!["displayName"]!;
918+
if (node != null)
919+
{
920+
var indicator = extendedMessage.ExtendedMetadata!["localizedResult"]!;
921+
var displayName = extendedMessage.ExtendedMetadata!["displayName"]!;
922+
923+
var status = new TerminalNodeStatus(node.Project, node.TargetFramework, TerminalColor.Green, indicator, displayName, project.Stopwatch);
924+
UpdateNodeStatus(buildEventContext, status);
925+
}
920926

921-
var status = new TerminalNodeStatus(node.Project, node.TargetFramework, TerminalColor.Green, indicator, displayName, project.Stopwatch);
922-
UpdateNodeStatus(buildEventContext, status);
923927
break;
924928
}
925929

926930
case "TLTESTSKIPPED":
927931
{
928-
var indicator = extendedMessage.ExtendedMetadata!["localizedResult"]!;
929-
var displayName = extendedMessage.ExtendedMetadata!["displayName"]!;
932+
if (node != null)
933+
{
934+
var indicator = extendedMessage.ExtendedMetadata!["localizedResult"]!;
935+
var displayName = extendedMessage.ExtendedMetadata!["displayName"]!;
936+
937+
var status = new TerminalNodeStatus(node.Project, node.TargetFramework, TerminalColor.Yellow, indicator, displayName, project.Stopwatch);
938+
UpdateNodeStatus(buildEventContext, status);
939+
}
930940

931-
var status = new TerminalNodeStatus(node.Project, node.TargetFramework, TerminalColor.Yellow, indicator, displayName, project.Stopwatch);
932-
UpdateNodeStatus(buildEventContext, status);
933941
break;
934942
}
935943

0 commit comments

Comments
 (0)