Skip to content

Show all type of messages( sdtOut, stdErr etc) for passed tests #809

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

Merged
merged 2 commits into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions src/vstest.console/Internal/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,19 @@ private static void DisplayFullInformation(TestResult result)
}
}

var DbgTrcMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.DebugTraceCategory);
if (DbgTrcMessagesCollection.Count > 0)
{
addAdditionalNewLine = false;
var dbgTrcMessages = GetFormattedOutput(DbgTrcMessagesCollection);

if (!string.IsNullOrEmpty(dbgTrcMessages))
{
Output.Information(CommandLineResources.DbgTrcMessagesBanner);
Output.Information(dbgTrcMessages);
}
}

var addnlInfoMessagesCollection = GetTestMessages(result.Messages, TestResultMessage.AdditionalInfoCategory);
if (addnlInfoMessagesCollection.Count > 0)
{
Expand All @@ -275,6 +288,7 @@ private static void DisplayFullInformation(TestResult result)
Output.Information(addnlInfoMessages);
}
}

if (addAdditionalNewLine)
{
Output.WriteLine(String.Empty, OutputLevel.Information);
Expand Down Expand Up @@ -354,6 +368,7 @@ private void TestResultHandler(object sender, TestResultEventArgs e)
{
var output = string.Format(CultureInfo.CurrentCulture, CommandLineResources.PassedTestIndicator, name);
Output.Information(output);
DisplayFullInformation(e.Result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Print DebugTraceCategory in DisplayFullInformation()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit

}
this.testsPassed++;
}
Expand Down
11 changes: 11 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.

3 changes: 3 additions & 0 deletions src/vstest.console/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -652,4 +652,7 @@
<data name="DataCollectorFriendlyNameInvalid" xml:space="preserve">
<value>The Data Collector friendly name '{0}' is not valid. The Data Collector will be ignored.</value>
</data>
<data name="DbgTrcMessagesBanner" xml:space="preserve">
<value>Debug Traces Messages:</value>
</data>
</root>
53 changes: 53 additions & 0 deletions test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,59 @@ public void TestResultHandlerShouldWriteToConsoleShouldShowPassedTestsForNormalV
this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.NotRunTestIndicator, "TestName"), OutputLevel.Information), Times.Exactly(2));
}

[TestMethod]
public void TestResultHandlerShouldShowStdOutMsgOfPassedTestIfVerbosityIsNormal()
{
var parameters = new Dictionary<string, string>();
parameters.Add("verbosity", "normal");
this.consoleLogger.Initialize(this.events.Object, parameters);

var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource");

string message = "Dummy message";
TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.StandardOutCategory, message);

var testresult = new ObjectModel.TestResult(testcase);
testresult.Outcome = TestOutcome.Passed;
testresult.Messages.Add(testResultMessage);

var eventArgs = new TestRunChangedEventArgs(null, new List<ObjectModel.TestResult> { testresult }, null);

// Raise an event on mock object
this.testRunRequest.Raise(m => m.OnRunStatsChange += null, eventArgs);
this.FlushLoggerMessages();

this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once());
}

[TestMethod]
public void TestResultHandlerShouldShowDbgTrcMsg()
{
var parameters = new Dictionary<string, string>();
parameters.Add("verbosity", "normal");
this.consoleLogger.Initialize(this.events.Object, parameters);

var testcase = new TestCase("TestName", new Uri("some://uri"), "TestSource");

string message = "Dummy message";
TestResultMessage testResultMessage = new TestResultMessage(TestResultMessage.DebugTraceCategory, message);

var testresult = new ObjectModel.TestResult(testcase);
testresult.Outcome = TestOutcome.Passed;
testresult.Messages.Add(testResultMessage);

var eventArgs = new TestRunChangedEventArgs(null, new List<ObjectModel.TestResult> { testresult }, null);

// Raise an event on mock object
this.testRunRequest.Raise(m => m.OnRunStatsChange += null, eventArgs);
this.FlushLoggerMessages();

this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.DbgTrcMessagesBanner, OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once());
}


[TestMethod]
public void TestResultHandlerShouldWriteToConsoleButSkipPassedTestsForMinimalVerbosity()
{
Expand Down