1010using Coverlet . Tests . Utils ;
1111using Newtonsoft . Json ;
1212using Xunit ;
13+ using Xunit . Sdk ;
1314
1415namespace Coverlet . Integration . Tests
1516{
@@ -87,8 +88,8 @@ private protected void AssertCoverage(string standardOutput = "", bool checkDete
8788 [ Fact ]
8889 public void Msbuild ( )
8990 {
90- string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName ) ;
91- string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName , ".binlog" ) ;
91+ string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName ) ;
92+ string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName , ".binlog" ) ;
9293 CreateDeterministicTestPropsFile ( ) ;
9394
9495 DotnetCli ( $ "build -c { _buildConfiguration } -bl:build.{ logFilename } /p:DeterministicSourcePaths=true", out string standardOutput , out string standardError , _testProjectPath ) ;
@@ -103,13 +104,13 @@ public void Msbuild()
103104 Assert . Contains ( "Build succeeded." , standardOutput ) ;
104105 string sourceRootMappingFilePath = Path . Combine ( _testBinaryPath , _buildConfiguration . ToLowerInvariant ( ) , "CoverletSourceRootsMapping_coverletsample.integration.determisticbuild" ) ;
105106 Assert . True ( File . Exists ( sourceRootMappingFilePath ) , $ "File not found: { sourceRootMappingFilePath } ") ;
106- Assert . True ( ! string . IsNullOrEmpty ( File . ReadAllText ( sourceRootMappingFilePath ) ) , "Empty CoverletSourceRootsMapping file" ) ;
107+ Assert . False ( string . IsNullOrEmpty ( File . ReadAllText ( sourceRootMappingFilePath ) ) ) ;
107108 Assert . Contains ( "=/_/" , File . ReadAllText ( sourceRootMappingFilePath ) ) ;
108109
109110 string testResultFile = Path . Join ( testResultPath , "coverage.json" ) ;
110111 string cmdArgument = $ "test -c { _buildConfiguration } --no-build /p:CollectCoverage=true /p:CoverletOutput=\" { testResultFile } \" /p:DeterministicReport=true /p:CoverletOutputFormat=\" cobertura%2cjson\" /p:Include=\" [coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true";
111112 _output . WriteLine ( $ "Command: dotnet { cmdArgument } ") ;
112- bool result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
113+ int result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
113114 if ( ! string . IsNullOrEmpty ( standardError ) )
114115 {
115116 _output . WriteLine ( standardError ) ;
@@ -118,7 +119,7 @@ public void Msbuild()
118119 {
119120 _output . WriteLine ( standardOutput ) ;
120121 }
121- Assert . True ( result ) ;
122+ Assert . Equal ( 0 , result ) ;
122123 Assert . Contains ( "Passed!" , standardOutput ) ;
123124 Assert . Contains ( "| coverletsample.integration.determisticbuild | 100% | 100% | 100% |" , standardOutput ) ;
124125 Assert . True ( File . Exists ( testResultFile ) ) ;
@@ -130,8 +131,8 @@ public void Msbuild()
130131 [ Fact ]
131132 public void Msbuild_SourceLink ( )
132133 {
133- string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName ) ;
134- string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName , ".binlog" ) ;
134+ string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName ) ;
135+ string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName , ".binlog" ) ;
135136 CreateDeterministicTestPropsFile ( ) ;
136137
137138 DotnetCli ( $ "build -c { _buildConfiguration } -bl:build.{ logFilename } --verbosity normal /p:DeterministicSourcePaths=true", out string standardOutput , out string standardError , _testProjectPath ) ;
@@ -147,13 +148,13 @@ public void Msbuild_SourceLink()
147148 string sourceRootMappingFilePath = Path . Combine ( _testBinaryPath , _buildConfiguration . ToLowerInvariant ( ) , "CoverletSourceRootsMapping_coverletsample.integration.determisticbuild" ) ;
148149
149150 Assert . True ( File . Exists ( sourceRootMappingFilePath ) , $ "File not found: { sourceRootMappingFilePath } ") ;
150- Assert . True ( ! string . IsNullOrEmpty ( File . ReadAllText ( sourceRootMappingFilePath ) ) , "Empty CoverletSourceRootsMapping file" ) ;
151+ Assert . False ( string . IsNullOrEmpty ( File . ReadAllText ( sourceRootMappingFilePath ) ) ) ;
151152 Assert . Contains ( "=/_/" , File . ReadAllText ( sourceRootMappingFilePath ) ) ;
152153
153154 string testResultFile = Path . Join ( testResultPath , "coverage.json" ) ;
154155 string cmdArgument = $ "test -c { _buildConfiguration } --no-build /p:CollectCoverage=true /p:CoverletOutput=\" { testResultFile } \" /p:CoverletOutputFormat=\" cobertura%2cjson\" /p:UseSourceLink=true /p:Include=\" [coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true";
155156 _output . WriteLine ( $ "Command: dotnet { cmdArgument } ") ;
156- bool result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
157+ int result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
157158 if ( ! string . IsNullOrEmpty ( standardError ) )
158159 {
159160 _output . WriteLine ( standardError ) ;
@@ -162,7 +163,7 @@ public void Msbuild_SourceLink()
162163 {
163164 _output . WriteLine ( standardOutput ) ;
164165 }
165- Assert . True ( result ) ;
166+ Assert . Equal ( 0 , result ) ;
166167 Assert . Contains ( "Passed!" , standardOutput ) ;
167168 Assert . Contains ( "| coverletsample.integration.determisticbuild | 100% | 100% | 100% |" , standardOutput ) ;
168169 Assert . True ( File . Exists ( testResultFile ) ) ;
@@ -175,9 +176,9 @@ public void Msbuild_SourceLink()
175176 [ Fact ]
176177 public void Collectors ( )
177178 {
178- string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName ) ;
179- string testLogFilesPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName , "log" ) ;
180- string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName , ".binlog" ) ;
179+ string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName ) ;
180+ string testLogFilesPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName , "log" ) ;
181+ string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName , ".binlog" ) ;
181182
182183 CreateDeterministicTestPropsFile ( ) ;
183184 DeleteLogFiles ( testLogFilesPath ) ;
@@ -202,7 +203,7 @@ public void Collectors()
202203 string runSettingsPath = AddCollectorRunsettingsFile ( _testProjectPath , "[coverletsample.integration.determisticbuild]*DeepThought" , deterministicReport : true ) ;
203204 string cmdArgument = $ "test -c { _buildConfiguration } --no-build --collect:\" XPlat Code Coverage\" --results-directory:\" { testResultPath } \" --settings \" { runSettingsPath } \" --diag:{ Path . Combine ( testLogFilesPath , "log.txt" ) } ";
204205 _output . WriteLine ( $ "Command: dotnet { cmdArgument } ") ;
205- bool result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
206+ int result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
206207 if ( ! string . IsNullOrEmpty ( standardError ) )
207208 {
208209 _output . WriteLine ( standardError ) ;
@@ -211,7 +212,7 @@ public void Collectors()
211212 {
212213 _output . WriteLine ( standardOutput ) ;
213214 }
214- Assert . True ( result ) ;
215+ Assert . Equal ( 0 , result ) ;
215216 Assert . Contains ( "Passed!" , standardOutput ) ;
216217 AssertCoverage ( standardOutput ) ;
217218
@@ -230,9 +231,9 @@ public void Collectors()
230231 [ Fact ]
231232 public void Collectors_SourceLink ( )
232233 {
233- string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName ) ;
234- string testLogFilesPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName , "log" ) ;
235- string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . DisplayName , ".binlog" ) ;
234+ string testResultPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName ) ;
235+ string testLogFilesPath = Path . Join ( _testResultsPath , ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName , "log" ) ;
236+ string logFilename = string . Concat ( ( ( ITest ) _testMember ! . GetValue ( _output ) ! ) . TestDisplayName , ".binlog" ) ;
236237
237238 CreateDeterministicTestPropsFile ( ) ;
238239 DeleteLogFiles ( testLogFilesPath ) ;
@@ -257,7 +258,7 @@ public void Collectors_SourceLink()
257258 string runSettingsPath = AddCollectorRunsettingsFile ( _testProjectPath , "[coverletsample.integration.determisticbuild]*DeepThought" , sourceLink : true ) ;
258259 string cmdArgument = $ "test -c { _buildConfiguration } --no-build --collect:\" XPlat Code Coverage\" --results-directory:\" { testResultPath } \" --settings \" { runSettingsPath } \" --diag:{ Path . Combine ( testLogFilesPath , "log.txt" ) } ";
259260 _output . WriteLine ( $ "Command: dotnet { cmdArgument } ") ;
260- bool result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
261+ int result = DotnetCli ( cmdArgument , out standardOutput , out standardError , _testProjectPath ) ;
261262 if ( ! string . IsNullOrEmpty ( standardError ) )
262263 {
263264 _output . WriteLine ( standardError ) ;
@@ -266,7 +267,7 @@ public void Collectors_SourceLink()
266267 {
267268 _output . WriteLine ( standardOutput ) ;
268269 }
269- Assert . True ( result ) ;
270+ Assert . Equal ( 0 , result ) ;
270271 Assert . Contains ( "Passed!" , standardOutput ) ;
271272 AssertCoverage ( standardOutput , checkDeterministicReport : false ) ;
272273
0 commit comments