|
3 | 3 |
|
4 | 4 | using System.IO; |
5 | 5 | using System.Linq; |
| 6 | +using Coverlet.Tests.Xunit.Extensions; |
6 | 7 | using Xunit; |
7 | 8 |
|
8 | 9 | namespace Coverlet.Integration.Tests |
9 | 10 | { |
10 | | - public class DotnetGlobalTools : BaseTest |
| 11 | + public class DotnetGlobalTools : BaseTest |
| 12 | + { |
| 13 | + private string InstallTool(string projectPath) |
11 | 14 | { |
12 | | - private string InstallTool(string projectPath) |
13 | | - { |
14 | | - _ = DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out _, projectPath); |
15 | | - Assert.Contains("was successfully installed.", standardOutput); |
16 | | - return Path.Combine(projectPath, "coverletTool", "coverlet"); |
17 | | - } |
| 15 | + _ = DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out _, projectPath); |
| 16 | + Assert.Contains("was successfully installed.", standardOutput); |
| 17 | + return Path.Combine(projectPath, "coverletTool", "coverlet"); |
| 18 | + } |
18 | 19 |
|
19 | | - [Fact] |
20 | | - public void DotnetTool() |
21 | | - { |
22 | | - using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
23 | | - UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
24 | | - string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
25 | | - DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
26 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
27 | | - RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError); |
28 | | - Assert.Contains("Passed!", standardOutput); |
29 | | - AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
30 | | - } |
| 20 | + [Fact] |
| 21 | + public void DotnetTool() |
| 22 | + { |
| 23 | + using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
| 24 | + UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
| 25 | + string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
| 26 | + DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
| 27 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
| 28 | + RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError); |
| 29 | + Assert.Contains("Passed!", standardOutput); |
| 30 | + AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
| 31 | + } |
31 | 32 |
|
32 | | - [Fact] |
33 | | - public void StandAlone() |
34 | | - { |
35 | | - using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
36 | | - UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
37 | | - string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
38 | | - DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
39 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
40 | | - RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError); |
41 | | - Assert.Contains("Hello World!", standardOutput); |
42 | | - AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
43 | | - } |
| 33 | + [Fact] |
| 34 | + public void StandAlone() |
| 35 | + { |
| 36 | + using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
| 37 | + UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
| 38 | + string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
| 39 | + DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
| 40 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
| 41 | + RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError); |
| 42 | + Assert.Contains("Hello World!", standardOutput); |
| 43 | + AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
| 44 | + } |
44 | 45 |
|
45 | | - [ConditionalFact] |
46 | | - [SkipOnOS(OS.Linux)] |
47 | | - [SkipOnOS(OS.MacOS)] |
48 | | - public void StandAloneThreshold() |
49 | | - { |
50 | | - using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
51 | | - UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
52 | | - string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
53 | | - DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
54 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
55 | | - Assert.False( RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError)); |
56 | | - Assert.Contains("Hello World!", standardOutput); |
57 | | - AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
58 | | - Assert.Contains("The minimum line coverage is below the specified 80", standardOutput); |
59 | | - Assert.Contains("The minimum method coverage is below the specified 80", standardOutput); |
60 | | - } |
| 46 | + [ConditionalFact] |
| 47 | + [SkipOnOS(OS.Linux)] |
| 48 | + [SkipOnOS(OS.MacOS)] |
| 49 | + public void StandAloneThreshold() |
| 50 | + { |
| 51 | + using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
| 52 | + UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
| 53 | + string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
| 54 | + DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
| 55 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
| 56 | + Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError)); |
| 57 | + Assert.Contains("Hello World!", standardOutput); |
| 58 | + AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
| 59 | + Assert.Contains("The minimum line coverage is below the specified 80", standardOutput); |
| 60 | + Assert.Contains("The minimum method coverage is below the specified 80", standardOutput); |
| 61 | + } |
61 | 62 |
|
62 | | - [ConditionalFact] |
63 | | - [SkipOnOS(OS.Linux)] |
64 | | - [SkipOnOS(OS.MacOS)] |
65 | | - public void StandAloneThresholdLine() |
66 | | - { |
67 | | - using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
68 | | - UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
69 | | - string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
70 | | - DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
71 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
72 | | - Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError)); |
73 | | - Assert.Contains("Hello World!", standardOutput); |
74 | | - AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
75 | | - Assert.Contains("The minimum line coverage is below the specified 80", standardOutput); |
76 | | - Assert.DoesNotContain("The minimum method coverage is below the specified 80", standardOutput); |
77 | | - } |
| 63 | + [ConditionalFact] |
| 64 | + [SkipOnOS(OS.Linux)] |
| 65 | + [SkipOnOS(OS.MacOS)] |
| 66 | + public void StandAloneThresholdLine() |
| 67 | + { |
| 68 | + using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
| 69 | + UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
| 70 | + string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
| 71 | + DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
| 72 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
| 73 | + Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError)); |
| 74 | + Assert.Contains("Hello World!", standardOutput); |
| 75 | + AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
| 76 | + Assert.Contains("The minimum line coverage is below the specified 80", standardOutput); |
| 77 | + Assert.DoesNotContain("The minimum method coverage is below the specified 80", standardOutput); |
| 78 | + } |
78 | 79 |
|
79 | | - [ConditionalFact] |
80 | | - [SkipOnOS(OS.Linux)] |
81 | | - [SkipOnOS(OS.MacOS)] |
82 | | - public void StandAloneThresholdLineAndMethod () |
83 | | - { |
84 | | - using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
85 | | - UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
86 | | - string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
87 | | - DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
88 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
89 | | - Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError)); |
90 | | - Assert.Contains("Hello World!", standardOutput); |
91 | | - AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
92 | | - Assert.Contains("The minimum line coverage is below the specified 80", standardOutput); |
93 | | - Assert.Contains("The minimum method coverage is below the specified 80", standardOutput); |
94 | | - } |
| 80 | + [ConditionalFact] |
| 81 | + [SkipOnOS(OS.Linux)] |
| 82 | + [SkipOnOS(OS.MacOS)] |
| 83 | + public void StandAloneThresholdLineAndMethod() |
| 84 | + { |
| 85 | + using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(); |
| 86 | + UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
| 87 | + string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!); |
| 88 | + DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError); |
| 89 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref")); |
| 90 | + Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError)); |
| 91 | + Assert.Contains("Hello World!", standardOutput); |
| 92 | + AssertCoverage(clonedTemplateProject, standardOutput: standardOutput); |
| 93 | + Assert.Contains("The minimum line coverage is below the specified 80", standardOutput); |
| 94 | + Assert.Contains("The minimum method coverage is below the specified 80", standardOutput); |
95 | 95 | } |
| 96 | + } |
96 | 97 | } |
0 commit comments