@@ -20,8 +20,9 @@ public DotnetGlobalTools(ITestOutputHelper output)
20
20
}
21
21
private string InstallTool ( string projectPath )
22
22
{
23
- _ = DotnetCli ( $ "tool install coverlet.console --version { GetPackageVersion ( "*console*.nupkg" ) } --tool-path \" { Path . Combine ( projectPath , "coverletTool" ) } \" ", out string standardOutput , out _ , projectPath ) ;
23
+ _ = DotnetCli ( $ "tool install coverlet.console --version { GetPackageVersion ( "*console*.nupkg" ) } --tool-path \" { Path . Combine ( projectPath , "coverletTool" ) } \" ", out string standardOutput , out string standardError , projectPath ) ;
24
24
Assert . Contains ( "was successfully installed." , standardOutput ) ;
25
+ Assert . Empty ( standardError ) ;
25
26
return Path . Combine ( projectPath , "coverletTool" , "coverlet" ) ;
26
27
}
27
28
@@ -71,7 +72,7 @@ public void StandAloneThreshold()
71
72
string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
72
73
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
73
74
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
74
- Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --output \" { outputPath } \" ", out standardOutput , out standardError ) ) ;
75
+ int cmdExitCode = RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --output \" { outputPath } \" ", out standardOutput , out standardError ) ;
75
76
if ( ! string . IsNullOrEmpty ( standardError ) )
76
77
{
77
78
_output . WriteLine ( standardError ) ;
@@ -84,8 +85,10 @@ public void StandAloneThreshold()
84
85
Assert . Contains ( "Hello World!" , standardOutput ) ;
85
86
Assert . True ( File . Exists ( outputPath ) ) ;
86
87
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
87
- Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
88
- Assert . Contains ( "The minimum method coverage is below the specified 80" , 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);
89
92
}
90
93
91
94
[ Fact ]
@@ -97,7 +100,7 @@ public void StandAloneThresholdLine()
97
100
string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
98
101
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
99
102
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
100
- Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --output \" { outputPath } \" ", out standardOutput , out standardError ) ) ;
103
+ int cmdExitCode = RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --output \" { outputPath } \" ", out standardOutput , out standardError ) ;
101
104
if ( ! string . IsNullOrEmpty ( standardError ) )
102
105
{
103
106
_output . WriteLine ( standardError ) ;
@@ -107,9 +110,10 @@ public void StandAloneThresholdLine()
107
110
// make standard output available in trx file
108
111
_output . WriteLine ( standardOutput ) ;
109
112
}
110
- Assert . Contains ( "Hello World!" , standardOutput ) ;
113
+ // Assert.Contains("Hello World!", standardOutput);
111
114
Assert . True ( File . Exists ( outputPath ) ) ;
112
115
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
116
+ Assert . Equal ( ( int ) CommandExitCodes . CoverageBelowThreshold , cmdExitCode ) ;
113
117
Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
114
118
Assert . DoesNotContain ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
115
119
}
@@ -123,7 +127,7 @@ public void StandAloneThresholdLineAndMethod()
123
127
string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
124
128
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
125
129
string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
126
- Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --threshold-type method --output \" { outputPath } \" ", out standardOutput , out standardError ) ) ;
130
+ int cmdExitCode = RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --threshold-type method --output \" { outputPath } \" ", out standardOutput , out standardError ) ;
127
131
if ( ! string . IsNullOrEmpty ( standardError ) )
128
132
{
129
133
_output . WriteLine ( standardError ) ;
@@ -133,9 +137,10 @@ public void StandAloneThresholdLineAndMethod()
133
137
// make standard output available in trx file
134
138
_output . WriteLine ( standardOutput ) ;
135
139
}
136
- Assert . Contains ( "Hello World!" , standardOutput ) ;
140
+ // Assert.Contains("Hello World!", standardOutput);
137
141
Assert . True ( File . Exists ( outputPath ) ) ;
138
142
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
143
+ Assert . Equal ( ( int ) CommandExitCodes . CoverageBelowThreshold , cmdExitCode ) ;
139
144
Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
140
145
Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
141
146
}
0 commit comments