Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Dec 11, 2023
1 parent 6207cae commit b7c457b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/coverlet.integration.tests/DotnetTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,28 @@ public void StandAloneThresholdLineAndMethod()
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
}

[Fact]
public void StandAlonePathMapping()
{
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
DotnetCli($"build {clonedTemplateProject.ProjectRootPath} /p:ContinuousIntegrationBuild=true", out string standardOutput, out string standardError);
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));

string mappingFile = Path.Combine(clonedTemplateProject.ProjectRootPath, "CoverletMapping.txt");
File.WriteAllLines(mappingFile, new string[]
{
$"|{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}=/_/"
});
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar} --use-mapping-file \"{mappingFile}\"", out standardOutput, out standardError);
if (!string.IsNullOrEmpty(standardError))
{
_output.WriteLine(standardError);
}
Assert.Contains("Passed!", standardOutput);
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
}
}
}

0 comments on commit b7c457b

Please sign in to comment.