Skip to content

Commit

Permalink
check null value for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertk committed Feb 23, 2023
1 parent da9cacf commit df81f69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions test/coverlet.integration.tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,16 @@ private protected void AssertCoverage(ClonedTemplateProject clonedTemplateProjec
bool coverageChecked = false;
foreach (string coverageFile in clonedTemplateProject.GetFiles(filter))
{
#pragma warning disable CS8604 // Possible null reference argument.
JsonConvert.DeserializeObject<Modules>(File.ReadAllText(coverageFile))
.Document("DeepThought.cs")
Modules? coverage = JsonConvert.DeserializeObject<Modules>(File.ReadAllText(coverageFile));
if (coverage != null)
{
coverage.Document("DeepThought.cs")
.Class("Coverlet.Integration.Template.DeepThought")
.Method("System.Int32 Coverlet.Integration.Template.DeepThought::AnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything()")
.AssertLinesCovered((6, 1), (7, 1), (8, 1));
#pragma warning restore CS8604 // Possible null reference argument.
coverageChecked = true;
}
}

Assert.True(coverageChecked, $"Coverage check fail\n{standardOutput}");
}
}
Expand Down
9 changes: 5 additions & 4 deletions test/coverlet.integration.tests/DeterministicBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ private protected void AssertCoverage(string standardOutput = "", bool checkDete
string reportFilePath = "";
foreach (string coverageFile in Directory.GetFiles(_testProjectPath, "coverage.json", SearchOption.AllDirectories))
{
#pragma warning disable CS8604 // Possible null reference argument.
JsonConvert.DeserializeObject<Modules>(File.ReadAllText(coverageFile))
.Document("DeepThought.cs")
Modules? coverage = JsonConvert.DeserializeObject<Modules>(File.ReadAllText(coverageFile));
if (coverage != null)
{
coverage.Document("DeepThought.cs")
.Class("Coverlet.Integration.DeterministicBuild.DeepThought")
.Method("System.Int32 Coverlet.Integration.DeterministicBuild.DeepThought::AnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything()")
.AssertLinesCovered((6, 1), (7, 1), (8, 1));
#pragma warning restore CS8604 // Possible null reference argument.
coverageChecked = true;
reportFilePath = coverageFile;
}
}
Assert.True(coverageChecked, $"Coverage check fail\n{standardOutput}");
File.Delete(reportFilePath);
Expand Down

0 comments on commit df81f69

Please sign in to comment.