Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console output for minimal and quiet #2191

Merged
merged 33 commits into from Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
795d3a8
added verbosity quiest
Sep 24, 2019
4da1046
removed source in printing
Sep 24, 2019
5bda2ee
added tests
Sep 26, 2019
103ee9e
added tests,changed private members of summary info to local members
Oct 3, 2019
afeda96
naming corrected
Oct 3, 2019
dbd9b7e
combined two for loops to one for loop
Oct 3, 2019
bfb5804
removed redundant code and fomatted
Oct 4, 2019
c952c42
modified resources
Oct 9, 2019
3391a72
added target framework in quiet case
Oct 21, 2019
ed14b11
added yellow colour to passed and skipped
Oct 23, 2019
3250de1
if cases formatted
Oct 24, 2019
d38829e
paased failed to localized
Oct 30, 2019
8ab3fa2
passed and failed in unit tests changed to localized
Oct 30, 2019
bf38a2e
summary added to verbosity minimal case also
Oct 30, 2019
c16c653
attachments added to minimal and quiet verbosity case
Nov 1, 2019
1b77242
Merge branch 'master' into ConsoleLoggerVerbosityQuietCase
singhsarab Nov 1, 2019
5075c6b
formatted
Nov 15, 2019
cae94bb
Merge branch 'ConsoleLoggerVerbosityQuietCase' of https://github.com/…
Nov 18, 2019
a742746
removed milliseconds unit when seconds unit is there
Nov 19, 2019
18c4022
Forward merge master
nohwnd Jan 8, 2020
a588684
Merge master again
nohwnd Jan 8, 2020
d22a535
Fix acceptance tests
nohwnd Jan 9, 2020
9ba8b23
Revert build changes
nohwnd Jan 9, 2020
6f3650a
Merge branch 'master' into ConsoleLoggerVerbosityQuietCase
nohwnd Apr 28, 2020
61859a5
Fix test
nohwnd May 28, 2020
75d50f2
Format output to align
nohwnd May 28, 2020
d36c66f
Fixing the output, not working adds new line
nohwnd May 28, 2020
b0ab8d4
Merge master
nohwnd Jul 13, 2020
8644107
check
nohwnd Jul 13, 2020
54aca6f
Minimal output
nohwnd Jul 13, 2020
6ad0add
Fix test
nohwnd Jul 13, 2020
c4a52e4
Write when aborting
nohwnd Jul 13, 2020
ea8b54b
Remove empty line
nohwnd Jul 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Microsoft.TestPlatform.ObjectModel/Logging/SourceSummary.cs
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging
{
using System;
public class SourceSummary
Copy link
Contributor

Choose a reason for hiding this comment

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

public class with no docs?

{
public int TotalTests { get; set; }
public int PassedTests { get; set; }
public int FailedTests { get; set; }
public int SkippedTests { get; set; }
public TimeSpan TimeSpan { get; set; }
}
}
66 changes: 53 additions & 13 deletions src/vstest.console/Internal/ConsoleLogger.cs
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
Expand All @@ -17,7 +18,6 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal
using Microsoft.VisualStudio.TestPlatform.Utilities;

using CommandLineResources = Resources.Resources;

/// <summary>
/// Logger for sending output to the console.
/// All the console logger messages prints to Standard Output with respective color, except OutputLevel.Error messages
Expand Down Expand Up @@ -107,10 +107,6 @@ internal enum Verbosity
private Verbosity verbosityLevel = Verbosity.Minimal;
#endif

private int testsTotal = 0;
private int testsPassed = 0;
private int testsFailed = 0;
private int testsSkipped = 0;
private bool testRunHasErrorMessages = false;

#endregion
Expand Down Expand Up @@ -155,6 +151,11 @@ protected static IOutput Output
/// </summary>
public Verbosity VerbosityLevel => verbosityLevel;

/// <summary>
/// Dictionary of summary of each source.
hvinett marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
private ConcurrentDictionary<string, SourceSummary> sourceSummaryDictionary { get; set; }

#endregion

#region ITestLoggerWithParameters
Expand All @@ -181,7 +182,7 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory)
// Progress indicator needs to be displayed only for cli experience.
this.progressIndicator = new ProgressIndicator(Output, new ConsoleHelper());
}

// Register for the events.
events.TestRunMessage += this.TestMessageHandler;
events.TestResult += this.TestResultHandler;
Expand All @@ -190,6 +191,7 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory)

// Register for the discovery events.
events.DiscoveryMessage += this.TestMessageHandler;
this.sourceSummaryDictionary = new ConcurrentDictionary<string, SourceSummary>();

// TODO Get changes from https://github.com/Microsoft/vstest/pull/1111/
// events.DiscoveredTests += DiscoveredTestsHandler;
Expand Down Expand Up @@ -467,10 +469,16 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
{
ValidateArg.NotNull<object>(sender, "sender");
ValidateArg.NotNull<TestResultEventArgs>(e, "e");
SourceSummary summary;
if (!this.sourceSummaryDictionary.TryGetValue(e.Result.TestCase.Source, out summary))
{
summary = new SourceSummary();
this.sourceSummaryDictionary.TryAdd(e.Result.TestCase.Source, summary);
}

// Update the test count statistics based on the result of the test.
this.testsTotal++;

summary.TotalTests++;
summary.TimeSpan += e.Result.Duration;
var testDisplayName = e.Result.DisplayName;

if (string.IsNullOrWhiteSpace(e.Result.DisplayName))
Expand All @@ -488,7 +496,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
{
case TestOutcome.Skipped:
{
this.testsSkipped++;
summary.SkippedTests++;
if (this.verbosityLevel == Verbosity.Quiet)
{
break;
Expand All @@ -512,12 +520,12 @@ private void TestResultHandler(object sender, TestResultEventArgs e)

case TestOutcome.Failed:
{
this.testsFailed++;
summary.FailedTests++;
if (this.verbosityLevel == Verbosity.Quiet)
{
break;
}

// Pause the progress indicator before displaying test result information
this.progressIndicator?.Pause();

Expand All @@ -533,7 +541,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)

case TestOutcome.Passed:
{
this.testsPassed++;
summary.PassedTests++;
if (this.verbosityLevel == Verbosity.Normal || this.verbosityLevel == Verbosity.Detailed)
{
// Pause the progress indicator before displaying test result information
Expand Down Expand Up @@ -619,7 +627,39 @@ private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
{
// Stop the progress indicator as we are about to print the summary
this.progressIndicator?.Stop();
SourceSummary summary;
var testsPassed = 0;
var testsFailed = 0;
var testsSkipped = 0;
var testsTotal = 0;
Output.WriteLine(string.Empty, OutputLevel.Information);
if (verbosityLevel == Verbosity.Quiet)
{
foreach (var sd in this.sourceSummaryDictionary.ToArray())
{
summary = this.sourceSummaryDictionary[sd.Key];

// Failed! Pass {1} Failed {2} skipped {3} Time : 233 se ({4})
if (summary.FailedTests > 0)
{
Output.Information(false, ConsoleColor.Red, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryFailed, summary.TotalTests, summary.PassedTests, summary.FailedTests, summary.SkippedTests, GetFormattedDurationString(summary.TimeSpan), sd.Key.Split('\\').Last()));
hvinett marked this conversation as resolved.
Show resolved Hide resolved
}
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
else
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
{
Output.Information(false, ConsoleColor.Green, string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryPassed, summary.TotalTests, summary.PassedTests, summary.FailedTests, summary.SkippedTests, GetFormattedDurationString(summary.TimeSpan), sd.Key.Split('\\').Last()));
}
}
return;
}

foreach (var sd in this.sourceSummaryDictionary.ToArray())
hvinett marked this conversation as resolved.
Show resolved Hide resolved
{
summary = this.sourceSummaryDictionary[sd.Key];
testsPassed = summary.PassedTests;
hvinett marked this conversation as resolved.
Show resolved Hide resolved
testsFailed = summary.FailedTests;
testsSkipped = summary.SkippedTests;
testsTotal = summary.TotalTests;
}

// Printing Run-level Attachments
var runLevelAttachementCount = (e.AttachmentSets == null) ? 0 : e.AttachmentSets.Sum(attachmentSet => attachmentSet.Attachments.Count);
Expand All @@ -644,7 +684,7 @@ private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
{
Output.Error(false, CommandLineResources.TestRunAborted);
}
else if (this.testsFailed > 0 || this.testRunHasErrorMessages)
else if (testsFailed > 0 || this.testRunHasErrorMessages)
{
Output.Error(false, CommandLineResources.TestRunFailed);
}
Expand Down
18 changes: 18 additions & 0 deletions src/vstest.console/Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/vstest.console/Resources/Resources.resx
Expand Up @@ -734,4 +734,10 @@
<data name="TestSourcesDiscovered" xml:space="preserve">
<value>A total of {0} test files matched the specified pattern.</value>
</data>
<data name="TestRunSummaryFailed" xml:space="preserve">
hvinett marked this conversation as resolved.
Show resolved Hide resolved
<value>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</value>
</data>
<data name="TestRunSummaryPassed" xml:space="preserve">
<value>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</value>
</data>
</root>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.cs.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">Celkový počet testovacích souborů, které odpovídají zadanému vzoru: {0}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.de.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">Insgesamt {0} Testdateien stimmten mit dem angegebenen Muster überein.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.es.xlf
Expand Up @@ -1659,6 +1659,16 @@
<target state="translated">{0} archivos de prueba en total coincidieron con el patrón especificado.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.fr.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">Au total, {0} fichiers de test ont correspondu au modèle spécifié.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.it.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">Un totale di {0} file di test corrisponde al criterio specificato.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ja.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">合計 {0} 個のテスト ファイルが指定されたパターンと一致しました。</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ko.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">지정된 패턴과 일치한 총 테스트 파일 수는 {0}개입니다.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.pl.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">Łączna liczba plików testowych dopasowanych do określonego wzorca: {0}.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.pt-BR.xlf
Expand Up @@ -1656,6 +1656,16 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a
<target state="translated">{0} arquivos de teste no total corresponderam ao padrão especificado.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ru.xlf
Expand Up @@ -1656,6 +1656,16 @@
<target state="translated">Общее количество тестовых файлов ({0}), соответствующих указанному шаблону.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryFailed">
<source>Failed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5}).</source>
<target state="new">Failed! Pass:{0} Fail:{1} Skip:{2} Time:{3} Source:{4}</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryPassed">
<source>Passed! Total: {0}. Pass: {1}. Fail: {2}. Skip: {3}. Time: {4}. ({5})</source>
<target state="new">Passed! Total:{0} Pass:{1} Fail:{2} Skip:{3} Time:{4} Source:{5}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>