Skip to content

Commit

Permalink
Fix console logger spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed May 31, 2022
1 parent ca7d537 commit a317579
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/vstest.console/Internal/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ internal class ConsoleLogger : ITestLoggerWithParameters
/// </summary>
private const string TestResultPrefix = " ";

/// <summary>
/// Suffix used for formatting the result output
/// </summary>
private const string TestResultSuffix = " ";

/// <summary>
/// Bool to decide whether Verbose level should be added as prefix or not in log messages.
/// </summary>
Expand Down Expand Up @@ -538,7 +543,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
// Pause the progress indicator before displaying test result information
_progressIndicator?.Pause();

Output.Write(TestResultPrefix + CommandLineResources.SkippedTestIndicator, OutputLevel.Information, ConsoleColor.Yellow);
Output.Write(GetFormattedTestIndicator(CommandLineResources.SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow);
Output.WriteLine(testDisplayName, OutputLevel.Information);
if (VerbosityLevel == Verbosity.Detailed)
{
Expand All @@ -561,7 +566,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
// Pause the progress indicator before displaying test result information
_progressIndicator?.Pause();

Output.Write(TestResultPrefix + CommandLineResources.FailedTestIndicator, OutputLevel.Information, ConsoleColor.Red);
Output.Write(GetFormattedTestIndicator(CommandLineResources.FailedTestIndicator), OutputLevel.Information, ConsoleColor.Red);
Output.WriteLine(testDisplayName, OutputLevel.Information);
DisplayFullInformation(e.Result);

Expand All @@ -578,7 +583,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
// Pause the progress indicator before displaying test result information
_progressIndicator?.Pause();

Output.Write(TestResultPrefix + CommandLineResources.PassedTestIndicator, OutputLevel.Information, ConsoleColor.Green);
Output.Write(GetFormattedTestIndicator(CommandLineResources.PassedTestIndicator), OutputLevel.Information, ConsoleColor.Green);
Output.WriteLine(testDisplayName, OutputLevel.Information);
if (VerbosityLevel == Verbosity.Detailed)
{
Expand All @@ -602,7 +607,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
// Pause the progress indicator before displaying test result information
_progressIndicator?.Pause();

Output.Write(TestResultPrefix + CommandLineResources.SkippedTestIndicator, OutputLevel.Information, ConsoleColor.Yellow);
Output.Write(GetFormattedTestIndicator(CommandLineResources.SkippedTestIndicator), OutputLevel.Information, ConsoleColor.Yellow);
Output.WriteLine(testDisplayName, OutputLevel.Information);
if (VerbosityLevel == Verbosity.Detailed)
{
Expand All @@ -615,6 +620,9 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
break;
}
}

// Local functions
static string GetFormattedTestIndicator(string indicator) => TestResultPrefix + indicator + TestResultSuffix;
}

private string GetFormattedDurationString(TimeSpan duration)
Expand Down

0 comments on commit a317579

Please sign in to comment.