@@ -61,13 +61,13 @@ private void CreateDeterministicTestPropsFile()
61
61
deterministicTestProps . Save ( Path . Combine ( propsFile ) ) ;
62
62
}
63
63
64
- private protected void AssertCoverage ( string standardOutput = "" , bool checkDeterministicReport = true )
64
+ private protected void AssertCoverage ( string standardOutput = "" , string reportName = "" , bool checkDeterministicReport = true )
65
65
{
66
66
if ( _buildConfiguration == "Debug" )
67
67
{
68
68
bool coverageChecked = false ;
69
69
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 ) )
71
71
{
72
72
Classes ? document = JsonConvert . DeserializeObject < Modules > ( File . ReadAllText ( coverageFile ) ) ? . Document ( "DeepThought.cs" ) ;
73
73
if ( document != null )
@@ -86,7 +86,7 @@ private protected void AssertCoverage(string standardOutput = "", bool checkDete
86
86
if ( checkDeterministicReport )
87
87
{
88
88
// 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 ) )
90
90
{
91
91
Assert . Contains ( "/_/test/coverlet.integration.determisticbuild/DeepThought.cs" , File . ReadAllText ( coverageFile ) ) ;
92
92
File . Delete ( coverageFile ) ;
@@ -131,9 +131,9 @@ public void Msbuild()
131
131
Assert . Equal ( 0 , result ) ;
132
132
Assert . Contains ( "Passed!" , standardOutput ) ;
133
133
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" ) ;
137
137
138
138
CleanupBuildOutput ( ) ;
139
139
}
@@ -175,10 +175,10 @@ public void Msbuild_SourceLink()
175
175
Assert . Equal ( 0 , result ) ;
176
176
Assert . Contains ( "Passed!" , standardOutput ) ;
177
177
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" ) ;
180
180
Assert . Contains ( "raw.githubusercontent.com" , File . ReadAllText ( testResultFile ) ) ;
181
- AssertCoverage ( standardOutput , checkDeterministicReport : false ) ;
181
+ AssertCoverage ( standardOutput , $ "coverage. { _buildTargetFramework } .json" , checkDeterministicReport : false ) ;
182
182
183
183
CleanupBuildOutput ( ) ;
184
184
}
@@ -224,7 +224,7 @@ public void Collectors()
224
224
}
225
225
Assert . Equal ( 0 , result ) ;
226
226
Assert . Contains ( "Passed!" , standardOutput ) ;
227
- AssertCoverage ( standardOutput ) ;
227
+ AssertCoverage ( standardOutput , "coverage.json" ) ;
228
228
229
229
// delete irrelevant generated files
230
230
DeleteTestIntermediateFiles ( testResultPath ) ;
@@ -279,7 +279,7 @@ public void Collectors_SourceLink()
279
279
}
280
280
Assert . Equal ( 0 , result ) ;
281
281
Assert . Contains ( "Passed!" , standardOutput ) ;
282
- AssertCoverage ( standardOutput , checkDeterministicReport : false ) ;
282
+ AssertCoverage ( standardOutput , "coverage.json" , checkDeterministicReport : false ) ;
283
283
284
284
// delete irrelevant generated files
285
285
DeleteTestIntermediateFiles ( testResultPath ) ;
@@ -376,10 +376,9 @@ private static void DeleteCoverageFiles(string directory)
376
376
}
377
377
}
378
378
379
- private string GetReportPath ( string standardOutput )
379
+ private string GetReportPath ( string standardOutput , string reportFileName = "" )
380
380
{
381
381
string reportPath = "" ;
382
- string reportFileName = $ "coverage.{ _buildTargetFramework } .json";
383
382
if ( standardOutput . Contains ( reportFileName ) )
384
383
{
385
384
reportPath = standardOutput . Split ( '\n ' ) . FirstOrDefault ( line => line . Contains ( reportFileName ) ) ! . TrimStart ( ) ;
0 commit comments