@@ -61,13 +61,13 @@ private void CreateDeterministicTestPropsFile()
6161 deterministicTestProps . Save ( Path . Combine ( propsFile ) ) ;
6262 }
6363
64- private protected void AssertCoverage ( string standardOutput = "" , bool checkDeterministicReport = true )
64+ private protected void AssertCoverage ( string standardOutput = "" , string reportName = "" , bool checkDeterministicReport = true )
6565 {
6666 if ( _buildConfiguration == "Debug" )
6767 {
6868 bool coverageChecked = false ;
6969 string reportFilePath = "" ;
70- foreach ( string coverageFile in Directory . GetFiles ( GetReportPath ( standardOutput ) , $ "coverage. { _buildTargetFramework } .json" , SearchOption . AllDirectories ) )
70+ foreach ( string coverageFile in Directory . GetFiles ( GetReportPath ( standardOutput , reportName ) , reportName , SearchOption . AllDirectories ) )
7171 {
7272 Classes ? document = JsonConvert . DeserializeObject < Modules > ( File . ReadAllText ( coverageFile ) ) ? . Document ( "DeepThought.cs" ) ;
7373 if ( document != null )
@@ -86,7 +86,7 @@ private protected void AssertCoverage(string standardOutput = "", bool checkDete
8686 if ( checkDeterministicReport )
8787 {
8888 // Verify deterministic report
89- foreach ( string coverageFile in Directory . GetFiles ( GetReportPath ( standardOutput ) , "coverage.cobertura.xml" , SearchOption . AllDirectories ) )
89+ foreach ( string coverageFile in Directory . GetFiles ( GetReportPath ( standardOutput , "coverage.cobertura.xml" ) , "coverage.cobertura.xml" , SearchOption . AllDirectories ) )
9090 {
9191 Assert . Contains ( "/_/test/coverlet.integration.determisticbuild/DeepThought.cs" , File . ReadAllText ( coverageFile ) ) ;
9292 File . Delete ( coverageFile ) ;
@@ -131,9 +131,9 @@ public void Msbuild()
131131 Assert . Equal ( 0 , result ) ;
132132 Assert . Contains ( "Passed!" , standardOutput ) ;
133133 Assert . Contains ( "| coverletsample.integration.determisticbuild | 100% | 100% | 100% |" , standardOutput ) ;
134- string testResultFile = Path . Join ( testResultPath , $ "coverage.{ _buildTargetFramework } .json") ;
135- Assert . True ( File . Exists ( testResultFile ) ) ;
136- AssertCoverage ( standardOutput ) ;
134+ string testResultFile = Path . Join ( _testProjectPath , $ "coverage.{ _buildTargetFramework } .json") ;
135+ Assert . True ( File . Exists ( testResultFile ) , $ "File ' { testResultFile } ' does not exist" ) ;
136+ AssertCoverage ( standardOutput , $ "coverage. { _buildTargetFramework } .json" ) ;
137137
138138 CleanupBuildOutput ( ) ;
139139 }
@@ -175,10 +175,10 @@ public void Msbuild_SourceLink()
175175 Assert . Equal ( 0 , result ) ;
176176 Assert . Contains ( "Passed!" , standardOutput ) ;
177177 Assert . Contains ( "| coverletsample.integration.determisticbuild | 100% | 100% | 100% |" , standardOutput ) ;
178- string testResultFile = Path . Join ( testResultPath , $ "coverage.{ _buildTargetFramework } .json") ;
179- Assert . True ( File . Exists ( testResultFile ) ) ;
178+ string testResultFile = Path . Join ( _testProjectPath , $ "coverage.{ _buildTargetFramework } .json") ;
179+ Assert . True ( File . Exists ( testResultFile ) , $ "File ' { testResultFile } ' does not exist" ) ;
180180 Assert . Contains ( "raw.githubusercontent.com" , File . ReadAllText ( testResultFile ) ) ;
181- AssertCoverage ( standardOutput , checkDeterministicReport : false ) ;
181+ AssertCoverage ( standardOutput , $ "coverage. { _buildTargetFramework } .json" , checkDeterministicReport : false ) ;
182182
183183 CleanupBuildOutput ( ) ;
184184 }
@@ -224,7 +224,7 @@ public void Collectors()
224224 }
225225 Assert . Equal ( 0 , result ) ;
226226 Assert . Contains ( "Passed!" , standardOutput ) ;
227- AssertCoverage ( standardOutput ) ;
227+ AssertCoverage ( standardOutput , "coverage.json" ) ;
228228
229229 // delete irrelevant generated files
230230 DeleteTestIntermediateFiles ( testResultPath ) ;
@@ -279,7 +279,7 @@ public void Collectors_SourceLink()
279279 }
280280 Assert . Equal ( 0 , result ) ;
281281 Assert . Contains ( "Passed!" , standardOutput ) ;
282- AssertCoverage ( standardOutput , checkDeterministicReport : false ) ;
282+ AssertCoverage ( standardOutput , "coverage.json" , checkDeterministicReport : false ) ;
283283
284284 // delete irrelevant generated files
285285 DeleteTestIntermediateFiles ( testResultPath ) ;
@@ -376,10 +376,9 @@ private static void DeleteCoverageFiles(string directory)
376376 }
377377 }
378378
379- private string GetReportPath ( string standardOutput )
379+ private string GetReportPath ( string standardOutput , string reportFileName = "" )
380380 {
381381 string reportPath = "" ;
382- string reportFileName = $ "coverage.{ _buildTargetFramework } .json";
383382 if ( standardOutput . Contains ( reportFileName ) )
384383 {
385384 reportPath = standardOutput . Split ( '\n ' ) . FirstOrDefault ( line => line . Contains ( reportFileName ) ) ! . TrimStart ( ) ;
0 commit comments