|
8 | 8 |
|
9 | 9 | namespace Coverlet.Integration.Tests |
10 | 10 | { |
11 | | - public class TestSDK_16_2_0 : Collectors |
| 11 | + public class TestSDK_17_5_0 : Collectors |
| 12 | + { |
| 13 | + public TestSDK_17_5_0() |
12 | 14 | { |
13 | | - public TestSDK_16_2_0() |
14 | | - { |
15 | | - TestSDKVersion = "16.2.0"; |
16 | | - } |
17 | | - |
18 | | - private protected override void AssertCollectorsInjection(ClonedTemplateProject clonedTemplateProject) |
19 | | - { |
20 | | - // Check out/in process collectors injection |
21 | | - Assert.Contains("[coverlet]", File.ReadAllText(clonedTemplateProject.GetFiles("log.datacollector.*.txt").Single())); |
22 | | - |
23 | | - // There is a bug in this SDK version https://github.com/microsoft/vstest/pull/2221 |
24 | | - // in-proc coverlet.collector.dll collector with version != 1.0.0.0 won't be loaded |
25 | | - // Assert.Contains("[coverlet]", File.ReadAllText(clonedTemplateProject.GetFiles("log.host.*.txt").Single())); |
26 | | - } |
| 15 | + TestSDKVersion = "17.5.0"; |
27 | 16 | } |
28 | 17 |
|
29 | | - public class TestSDK_16_5_0 : Collectors |
| 18 | + private protected override void AssertCollectorsInjection(ClonedTemplateProject clonedTemplateProject) |
30 | 19 | { |
31 | | - public TestSDK_16_5_0() |
32 | | - { |
33 | | - TestSDKVersion = "16.5.0"; |
34 | | - } |
| 20 | + // Check out/in process collectors injection |
| 21 | + Assert.Contains("[coverlet]", File.ReadAllText(clonedTemplateProject.GetFiles("log.datacollector.*.txt").Single())); |
| 22 | + |
| 23 | + // There is a bug in this SDK version https://github.com/microsoft/vstest/pull/2221 |
| 24 | + // in-proc coverlet.collector.dll collector with version != 1.0.0.0 won't be loaded |
| 25 | + // Assert.Contains("[coverlet]", File.ReadAllText(clonedTemplateProject.GetFiles("log.host.*.txt").Single())); |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + public class TestSDK_17_6_0 : Collectors |
| 30 | + { |
| 31 | + public TestSDK_17_6_0() |
| 32 | + { |
| 33 | + TestSDKVersion = "17.6.0"; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + public class TestSDK_Preview : Collectors |
| 38 | + { |
| 39 | + public TestSDK_Preview() |
| 40 | + { |
| 41 | + TestSDKVersion = "17.7.0-preview-23364-03"; |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + public abstract class Collectors : BaseTest |
| 46 | + { |
| 47 | + private readonly string _buildConfiguration; |
| 48 | + |
| 49 | + public Collectors() |
| 50 | + { |
| 51 | + _buildConfiguration = GetAssemblyBuildConfiguration().ToString(); |
| 52 | + } |
| 53 | + |
| 54 | + protected string? TestSDKVersion { get; set; } |
| 55 | + |
| 56 | + private ClonedTemplateProject PrepareTemplateProject() |
| 57 | + { |
| 58 | + if (TestSDKVersion is null) |
| 59 | + { |
| 60 | + throw new ArgumentNullException("Invalid TestSDKVersion"); |
| 61 | + } |
| 62 | + |
| 63 | + ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(testSDKVersion: TestSDKVersion); |
| 64 | + UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
| 65 | + AddCoverletCollectosRef(clonedTemplateProject.ProjectRootPath!); |
| 66 | + return clonedTemplateProject; |
| 67 | + } |
| 68 | + |
| 69 | + private protected virtual void AssertCollectorsInjection(ClonedTemplateProject clonedTemplateProject) |
| 70 | + { |
| 71 | + // Check out/in process collectors injection |
| 72 | + Assert.Contains("[coverlet]Initializing CoverletCoverageDataCollector with configuration:", File.ReadAllText(clonedTemplateProject.GetFiles("log.datacollector.*.txt").Single())); |
| 73 | + Assert.Contains("[coverlet]Initialize CoverletInProcDataCollector", File.ReadAllText(clonedTemplateProject.GetFiles("log.host.*.txt").Single())); |
| 74 | + } |
| 75 | + |
| 76 | + [Fact] |
| 77 | + public void TestVsTest_Test() |
| 78 | + { |
| 79 | + using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
| 80 | + Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); |
| 81 | + // We don't have any result to check because tests and code to instrument are in same assembly so we need to pass |
| 82 | + // IncludeTestAssembly=true we do it in other test |
| 83 | + Assert.Contains("Passed!", standardOutput); |
| 84 | + AssertCollectorsInjection(clonedTemplateProject); |
| 85 | + } |
| 86 | + |
| 87 | + [Fact] |
| 88 | + public void TestVsTest_Test_Settings() |
| 89 | + { |
| 90 | + using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
| 91 | + string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!); |
| 92 | + Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError), standardOutput); |
| 93 | + Assert.Contains("Passed!", standardOutput); |
| 94 | + AssertCoverage(clonedTemplateProject); |
| 95 | + AssertCollectorsInjection(clonedTemplateProject); |
35 | 96 | } |
36 | 97 |
|
37 | | - public class TestSDK_Preview : Collectors |
| 98 | + [Fact] |
| 99 | + public void TestVsTest_VsTest() |
38 | 100 | { |
39 | | - public TestSDK_Preview() |
40 | | - { |
41 | | - TestSDKVersion = "16.5.0-preview-20200203-01"; |
42 | | - } |
| 101 | + using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
| 102 | + string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!); |
| 103 | + Assert.True(DotnetCli($"publish -c {_buildConfiguration} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError), standardOutput); |
| 104 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish")); |
| 105 | + Assert.NotNull(publishedTestFile); |
| 106 | + Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput); |
| 107 | + // We don't have any result to check because tests and code to instrument are in same assembly so we need to pass |
| 108 | + // IncludeTestAssembly=true we do it in other test |
| 109 | + Assert.Contains("Passed!", standardOutput); |
| 110 | + AssertCollectorsInjection(clonedTemplateProject); |
43 | 111 | } |
44 | 112 |
|
45 | | - public abstract class Collectors : BaseTest |
| 113 | + [Fact] |
| 114 | + public void TestVsTest_VsTest_Settings() |
46 | 115 | { |
47 | | - private readonly string _buildConfiguration; |
48 | | - |
49 | | - public Collectors() |
50 | | - { |
51 | | - _buildConfiguration = GetAssemblyBuildConfiguration().ToString(); |
52 | | - } |
53 | | - |
54 | | - protected string? TestSDKVersion { get; set; } |
55 | | - |
56 | | - private ClonedTemplateProject PrepareTemplateProject() |
57 | | - { |
58 | | - if (TestSDKVersion is null) |
59 | | - { |
60 | | - throw new ArgumentNullException("Invalid TestSDKVersion"); |
61 | | - } |
62 | | - |
63 | | - ClonedTemplateProject clonedTemplateProject = CloneTemplateProject(testSDKVersion: TestSDKVersion); |
64 | | - UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!); |
65 | | - AddCoverletCollectosRef(clonedTemplateProject.ProjectRootPath!); |
66 | | - return clonedTemplateProject; |
67 | | - } |
68 | | - |
69 | | - private protected virtual void AssertCollectorsInjection(ClonedTemplateProject clonedTemplateProject) |
70 | | - { |
71 | | - // Check out/in process collectors injection |
72 | | - Assert.Contains("[coverlet]Initializing CoverletCoverageDataCollector with configuration:", File.ReadAllText(clonedTemplateProject.GetFiles("log.datacollector.*.txt").Single())); |
73 | | - Assert.Contains("[coverlet]Initialize CoverletInProcDataCollector", File.ReadAllText(clonedTemplateProject.GetFiles("log.host.*.txt").Single())); |
74 | | - } |
75 | | - |
76 | | - [Fact] |
77 | | - public void TestVsTest_Test() |
78 | | - { |
79 | | - using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
80 | | - Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); |
81 | | - // We don't have any result to check because tests and code to instrument are in same assembly so we need to pass |
82 | | - // IncludeTestAssembly=true we do it in other test |
83 | | - Assert.Contains("Passed!", standardOutput); |
84 | | - AssertCollectorsInjection(clonedTemplateProject); |
85 | | - } |
86 | | - |
87 | | - [Fact] |
88 | | - public void TestVsTest_Test_Settings() |
89 | | - { |
90 | | - using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
91 | | - string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!); |
92 | | - Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError), standardOutput); |
93 | | - Assert.Contains("Passed!", standardOutput); |
94 | | - AssertCoverage(clonedTemplateProject); |
95 | | - AssertCollectorsInjection(clonedTemplateProject); |
96 | | - } |
97 | | - |
98 | | - [Fact] |
99 | | - public void TestVsTest_VsTest() |
100 | | - { |
101 | | - using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
102 | | - string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!); |
103 | | - Assert.True(DotnetCli($"publish -c {_buildConfiguration} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError), standardOutput); |
104 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish")); |
105 | | - Assert.NotNull(publishedTestFile); |
106 | | - Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput); |
107 | | - // We don't have any result to check because tests and code to instrument are in same assembly so we need to pass |
108 | | - // IncludeTestAssembly=true we do it in other test |
109 | | - Assert.Contains("Passed!", standardOutput); |
110 | | - AssertCollectorsInjection(clonedTemplateProject); |
111 | | - } |
112 | | - |
113 | | - [Fact] |
114 | | - public void TestVsTest_VsTest_Settings() |
115 | | - { |
116 | | - using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
117 | | - string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!); |
118 | | - Assert.True(DotnetCli($"publish -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\"", out string standardOutput, out string standardError), standardOutput); |
119 | | - string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish")); |
120 | | - Assert.NotNull(publishedTestFile); |
121 | | - Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --ResultsDirectory:\"{clonedTemplateProject.ProjectRootPath}\" /settings:\"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput); |
122 | | - Assert.Contains("Passed!", standardOutput); |
123 | | - AssertCoverage(clonedTemplateProject); |
124 | | - AssertCollectorsInjection(clonedTemplateProject); |
125 | | - } |
| 116 | + using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); |
| 117 | + string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!); |
| 118 | + Assert.True(DotnetCli($"publish -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\"", out string standardOutput, out string standardError), standardOutput); |
| 119 | + string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish")); |
| 120 | + Assert.NotNull(publishedTestFile); |
| 121 | + Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --ResultsDirectory:\"{clonedTemplateProject.ProjectRootPath}\" /settings:\"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput); |
| 122 | + Assert.Contains("Passed!", standardOutput); |
| 123 | + AssertCoverage(clonedTemplateProject); |
| 124 | + AssertCollectorsInjection(clonedTemplateProject); |
126 | 125 | } |
| 126 | + } |
127 | 127 | } |
0 commit comments