Skip to content

Commit

Permalink
Show total test = unknown if tests is aborted or canceled (#990)
Browse files Browse the repository at this point in the history
* Show total test = unknown if tests is aborted or canceled

* Fix tests
  • Loading branch information
Faizan2304 committed Aug 14, 2017
1 parent 123adc3 commit 069e859
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/vstest.console/Internal/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,18 @@ private void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
// Output a summary.
if (this.testsTotal > 0)
{
Output.Information(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, testsTotal, testsPassed, testsFailed, testsSkipped));
string testCountDetails;

if(e.IsAborted || e.IsCanceled)
{
testCountDetails = string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun, testsPassed, testsFailed, testsSkipped);
}
else
{
testCountDetails = string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, testsTotal, testsPassed, testsFailed, testsSkipped);
}

Output.Information(testCountDetails);

if (e.IsCanceled)
{
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 @@ -672,4 +672,7 @@
<data name="TestRunCanceled" xml:space="preserve">
<value>Test Run Canceled.</value>
</data>
<data name="TestRunSummaryForCanceledOrAbortedRun" xml:space="preserve">
<value>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</value>
</data>
</root>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@
Read response file for more options.</target>
<note></note>
</trans-unit>
<trans-unit id="TestRunSummaryForCanceledOrAbortedRun">
<source>Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</source>
<target state="new">Total tests: Unknown. Passed: {0}. Failed: {1}. Skipped: {2}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.PlatformAbstractions\Microsoft.TestPlatform.PlatformAbstractions.csproj"/>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.PlatformAbstractions\Microsoft.TestPlatform.PlatformAbstractions.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System.Runtime" />
Expand Down
32 changes: 30 additions & 2 deletions test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,38 @@ public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsCanceled()
// Raise an event on mock object
this.testRunRequest.Raise(m => m.OnRunCompletion += null, new TestRunCompleteEventArgs(null, true, false, null, null, new TimeSpan(1, 0, 0, 0)));

this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, 1, 0, 1, 0), OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun, 0, 1, 0), OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunCanceled, OutputLevel.Error), Times.Once());
}

[TestMethod]
public void TestRunCompleteHandlerShouldNotWriteTolatTestToConsoleIfTestsCanceled()
{
// Raise an event on mock object raised to register test case count and mark Outcome as Outcome.Failed
var eventArgs = new TestRunChangedEventArgs(null, this.GetTestResultObject(TestOutcome.Failed), null);
this.testRunRequest.Raise(m => m.OnRunStatsChange += null, eventArgs);

// Raise an event on mock object
this.testRunRequest.Raise(m => m.OnRunCompletion += null, new TestRunCompleteEventArgs(null, true, false, null, null, new TimeSpan(1, 0, 0, 0)));

this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun, 0, 1, 0), OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunCanceled, OutputLevel.Error), Times.Once());
}

[TestMethod]
public void TestRunCompleteHandlerShouldNotWriteTolatTestToConsoleIfTestsAborted()
{
// Raise an event on mock object raised to register test case count and mark Outcome as Outcome.Failed
var eventArgs = new TestRunChangedEventArgs(null, this.GetTestResultObject(TestOutcome.Failed), null);
this.testRunRequest.Raise(m => m.OnRunStatsChange += null, eventArgs);

// Raise an event on mock object
this.testRunRequest.Raise(m => m.OnRunCompletion += null, new TestRunCompleteEventArgs(null, false, true, null, null, new TimeSpan(1, 0, 0, 0)));

this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun, 0, 1, 0), OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once());
}

[TestMethod]
public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAborted()
{
Expand All @@ -466,7 +494,7 @@ public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAborted()
// Raise an event on mock object
this.testRunRequest.Raise(m => m.OnRunCompletion += null, new TestRunCompleteEventArgs(null, false, true, null, null, new TimeSpan(1, 0, 0, 0)));

this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummary, 1, 0, 1, 0), OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestRunSummaryForCanceledOrAbortedRun, 0, 1, 0), OutputLevel.Information), Times.Once());
this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once());
}

Expand Down

0 comments on commit 069e859

Please sign in to comment.