-
Notifications
You must be signed in to change notification settings - Fork 388
/
DotnetTool.cs
36 lines (33 loc) · 1.94 KB
/
DotnetTool.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Xunit;
namespace Coverlet.Integration.Tests
{
public class DotnetGlobalTools : BaseTest
{
private string InstallTool(string projectPath)
{
DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out string standardError, projectPath);
Assert.Contains("was successfully installed.", standardOutput);
return Path.Combine(projectPath, "coverletTool", "coverlet ");
}
[Fact]
public void DotnetTool()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Disabled for the moment on unix system we get an exception(folder access denied) during tool installation
return;
}
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj"));
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError);
Assert.Contains("Test Run Successful.", standardOutput);
AssertCoverage(clonedTemplateProject);
}
}
}