Skip to content

Commit 16cdd64

Browse files
committed
display errors in test detail summary
1 parent c9abe80 commit 16cdd64

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,3 @@ test/coverlet.integration.determisticbuild/*.txt
306306
test/coverlet.integration.determisticbuild/runsettings
307307

308308
coverage.cobertura.xml
309-
310-
cleanup-coverage-result.bat
311-

test/coverlet.integration.tests/DotnetTool.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
using System.Linq;
66
using Coverlet.Tests.Xunit.Extensions;
77
using Xunit;
8+
using Xunit.Abstractions;
89

910
namespace Coverlet.Integration.Tests
1011
{
1112
public class DotnetGlobalTools : BaseTest
1213
{
14+
private readonly ITestOutputHelper _output;
15+
16+
public DotnetGlobalTools(ITestOutputHelper output)
17+
{
18+
_output = output;
19+
}
1320
private string InstallTool(string projectPath)
1421
{
1522
_ = DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out _, projectPath);
@@ -26,6 +33,10 @@ public void DotnetTool()
2633
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
2734
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
2835
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
36+
if (!string.IsNullOrEmpty(standardError))
37+
{
38+
_output.WriteLine(standardError);
39+
}
2940
Assert.Contains("Passed!", standardOutput);
3041
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
3142
}
@@ -39,6 +50,10 @@ public void StandAlone()
3950
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
4051
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
4152
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
53+
if (!string.IsNullOrEmpty(standardError))
54+
{
55+
_output.WriteLine(standardError);
56+
}
4257
Assert.Contains("Hello World!", standardOutput);
4358
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
4459
}
@@ -54,6 +69,10 @@ public void StandAloneThreshold()
5469
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
5570
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
5671
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
72+
if (!string.IsNullOrEmpty(standardError))
73+
{
74+
_output.WriteLine(standardError);
75+
}
5776
Assert.Contains("Hello World!", standardOutput);
5877
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
5978
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
@@ -71,6 +90,10 @@ public void StandAloneThresholdLine()
7190
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
7291
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
7392
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
93+
if (!string.IsNullOrEmpty(standardError))
94+
{
95+
_output.WriteLine(standardError);
96+
}
7497
Assert.Contains("Hello World!", standardOutput);
7598
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
7699
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
@@ -88,6 +111,10 @@ public void StandAloneThresholdLineAndMethod()
88111
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
89112
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
90113
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
114+
if (!string.IsNullOrEmpty(standardError))
115+
{
116+
_output.WriteLine(standardError);
117+
}
91118
Assert.Contains("Hello World!", standardOutput);
92119
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
93120
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);

0 commit comments

Comments
 (0)