@@ -35,13 +35,14 @@ public void DotnetTool()
35
35
string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
36
36
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string buildOutput , out string buildError ) ;
37
37
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
38
- RunCommand ( coverletToolCommandPath , $ "\" { publishedTestFile } \" --target \" dotnet\" --targetargs \" test { Path . Combine ( clonedTemplateProject . ProjectRootPath , ClonedTemplateProject . ProjectFileName ) } --no-build\" --include-test-assembly --output \" { outputPath } \" ", out string standardOutput , out string standardError ) ;
38
+ int cmdExitCode = RunCommand ( coverletToolCommandPath , $ "\" { publishedTestFile } \" --target \" dotnet\" --targetargs \" test { Path . Combine ( clonedTemplateProject . ProjectRootPath , ClonedTemplateProject . ProjectFileName ) } --no-build\" --include-test-assembly --output \" { outputPath } \" ", out string standardOutput , out string standardError ) ;
39
39
if ( ! string . IsNullOrEmpty ( standardError ) )
40
40
{
41
41
_output . WriteLine ( standardError ) ;
42
42
}
43
43
Assert . Contains ( "Passed!" , standardOutput ) ;
44
44
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
45
+ Assert . Equal ( ( int ) CommandExitCodes . Success , cmdExitCode ) ;
45
46
}
46
47
47
48
[ Fact ]
@@ -53,14 +54,15 @@ public void StandAlone()
53
54
string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
54
55
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string buildOutput , out string buildError ) ;
55
56
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
56
- RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --output \" { outputPath } \" ", out string standardOutput , out string standardError ) ;
57
+ int cmdExitCode = RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --output \" { outputPath } \" ", out string standardOutput , out string standardError ) ;
57
58
if ( ! string . IsNullOrEmpty ( standardError ) )
58
59
{
59
60
_output . WriteLine ( standardError ) ;
60
61
}
61
62
//Assert.Contains("Hello World!", standardOutput);
62
63
Assert . True ( File . Exists ( outputPath ) ) ;
63
64
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
65
+ Assert . Equal ( ( int ) CommandExitCodes . Success , cmdExitCode ) ;
64
66
}
65
67
66
68
[ Fact ]
@@ -85,10 +87,9 @@ public void StandAloneThreshold()
85
87
//Assert.Contains("Hello World!", standardOutput);
86
88
Assert . True ( File . Exists ( outputPath ) ) ;
87
89
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
88
- //Assert.Equal((int)CommandExitCodes.CoverageBelowThreshold, cmdExitCode);
89
- // this messages are now in stderr available but standardError stream is empty in test environment
90
- //Assert.Contains("The minimum line coverage is below the specified 80", standardError);
91
- //Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
90
+ Assert . Equal ( ( int ) CommandExitCodes . CoverageBelowThreshold , cmdExitCode ) ;
91
+ Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
92
+ Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
92
93
}
93
94
94
95
[ Fact ]
@@ -113,9 +114,9 @@ public void StandAloneThresholdLine()
113
114
// Assert.Contains("Hello World!", standardOutput);
114
115
Assert . True ( File . Exists ( outputPath ) ) ;
115
116
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
116
- // Assert.Equal((int)CommandExitCodes.CoverageBelowThreshold, cmdExitCode);
117
- // Assert.Contains("The minimum line coverage is below the specified 80", standardError );
118
- // Assert.DoesNotContain("The minimum method coverage is below the specified 80", standardOutput);
117
+ Assert . Equal ( ( int ) CommandExitCodes . CoverageBelowThreshold , cmdExitCode ) ;
118
+ Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
119
+ Assert . DoesNotContain ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
119
120
}
120
121
121
122
[ Fact ]
@@ -140,9 +141,9 @@ public void StandAloneThresholdLineAndMethod()
140
141
// Assert.Contains("Hello World!", standardOutput);
141
142
Assert . True ( File . Exists ( outputPath ) ) ;
142
143
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
143
- // Assert.Equal((int)CommandExitCodes.CoverageBelowThreshold, cmdExitCode);
144
- // Assert.Contains("The minimum line coverage is below the specified 80", standardError );
145
- // Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
144
+ Assert . Equal ( ( int ) CommandExitCodes . CoverageBelowThreshold , cmdExitCode ) ;
145
+ Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
146
+ Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
146
147
}
147
148
}
148
149
}
0 commit comments