-
Notifications
You must be signed in to change notification settings - Fork 152
/
package-tests.cake
343 lines (299 loc) · 13.3 KB
/
package-tests.cake
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
// Tests run for all runner packages except NETCORE runner
var StandardRunnerTests = new List<PackageTest>();
// Tests run for the NETCORE runner package
var NetCoreRunnerTests = new List<PackageTest>();
// Method for adding to both lists
void AddToBothLists(PackageTest test)
{
StandardRunnerTests.Add(test);
NetCoreRunnerTests.Add(test);
}
//////////////////////////////////////////////////////////////////////
// RUN MOCK-ASSEMBLY UNDER EACH RUNTIME
//////////////////////////////////////////////////////////////////////
class MockAssemblyExpectedResult : ExpectedResult
{
public MockAssemblyExpectedResult(params string[] runtimes) : base("Failed")
{
int nCopies = runtimes.Length;
Total = 37 * nCopies;
Passed = 23 * nCopies;
Failed = 5 * nCopies;
Warnings = 1 * nCopies;
Inconclusive = 1 * nCopies;
Skipped = 7 * nCopies;
Assemblies = new ExpectedAssemblyResult[nCopies];
for (int i = 0; i < nCopies; i++)
Assemblies[i] = new ExpectedAssemblyResult("mock-assembly.dll", runtimes[i]);
}
}
StandardRunnerTests.Add(new PackageTest(
1, "Net462Test",
"Run mock-assembly.dll under .NET 4.6.2",
"testdata/net462/mock-assembly.dll",
new MockAssemblyExpectedResult("net-4.6.2")));
AddToBothLists(new PackageTest(
1, "Net80Test",
"Run mock-assembly.dll under .NET 8.0",
"testdata/net8.0/mock-assembly.dll",
new MockAssemblyExpectedResult("netcore-8.0")));
AddToBothLists(new PackageTest(
1, "Net70Test",
"Run mock-assembly.dll under .NET 7.0",
"testdata/net7.0/mock-assembly.dll",
new MockAssemblyExpectedResult("netcore-7.0")));
AddToBothLists(new PackageTest(
1, "Net60Test",
"Run mock-assembly.dll under .NET 6.0",
"testdata/net6.0/mock-assembly.dll",
new MockAssemblyExpectedResult("netcore-6.0")));
AddToBothLists(new PackageTest(
1, "NetCore31Test",
"Run mock-assembly.dll under .NET Core 3.1",
"testdata/netcoreapp3.1/mock-assembly.dll",
new MockAssemblyExpectedResult("netcore-3.1")));
//////////////////////////////////////////////////////////////////////
// RUN MOCK-ASSEMBLY-X86 UNDER EACH RUNTIME
//////////////////////////////////////////////////////////////////////
const string DOTNET_EXE_X86 = @"C:\Program Files (x86)\dotnet\dotnet.exe";
// TODO: Remove the limitation to Windows
bool dotnetX86Available = IsRunningOnWindows() && System.IO.File.Exists(DOTNET_EXE_X86);
class MockAssemblyX86ExpectedResult : MockAssemblyExpectedResult
{
public MockAssemblyX86ExpectedResult(params string[] runtimes) : base(runtimes)
{
for (int i = 0; i < runtimes.Length; i++)
Assemblies[i] = new ExpectedAssemblyResult("mock-assembly-x86.dll", runtimes[i]);
}
}
// X86 is always available for .NET Framework
StandardRunnerTests.Add(new PackageTest(
1, "Net462X86Test",
"Run mock-assembly-x86.dll under .NET 4.6.2",
"testdata/net462/mock-assembly-x86.dll",
new MockAssemblyX86ExpectedResult("net-4.6.2")));
if (dotnetX86Available)
{
// TODO: Make tests run on all build platforms
bool onAppVeyor = BuildSystem.IsRunningOnAppVeyor;
bool onGitHubActions = BuildSystem.IsRunningOnGitHubActions;
if (!onAppVeyor)
StandardRunnerTests.Add(new PackageTest(
1, "Net80X86Test",
"Run mock-assembly-x86.dll under .NET 8.0",
"testdata/net8.0/mock-assembly-x86.dll",
new MockAssemblyX86ExpectedResult("netcore-8.0")));
if (!onAppVeyor && !onGitHubActions)
StandardRunnerTests.Add(new PackageTest(
1, "Net70X86Test",
"Run mock-assembly-x86.dll under .NET 7.0",
"testdata/net7.0/mock-assembly-x86.dll",
new MockAssemblyX86ExpectedResult("netcore-7.0")));
StandardRunnerTests.Add(new PackageTest(
1, "Net60X86Test",
"Run mock-assembly-x86.dll under .NET 6.0",
"testdata/net6.0/mock-assembly-x86.dll",
new MockAssemblyX86ExpectedResult("netcore-6.0")));
if (!onAppVeyor && !onGitHubActions)
StandardRunnerTests.Add(new PackageTest(
1, "NetCore31X86Test",
"Run mock-assembly-x86.dll under .NET Core 3.1",
"testdata/netcoreapp3.1/mock-assembly-x86.dll",
new MockAssemblyX86ExpectedResult("netcore-3.1")));
}
//////////////////////////////////////////////////////////////////////
// RUN MULTIPLE COPIES OF MOCK-ASSEMBLY
//////////////////////////////////////////////////////////////////////
StandardRunnerTests.Add(new PackageTest(
1, "Net462PlusNet462Test",
"Run two copies of mock-assembly together",
"testdata/net462/mock-assembly.dll testdata/net462/mock-assembly.dll",
new MockAssemblyExpectedResult("net-4.6.2", "net-4.6.2")));
StandardRunnerTests.Add(new PackageTest(
1, "Net60PlusNet80Test",
"Run mock-assembly under .NET6.0 and 8.0 together",
"testdata/net6.0/mock-assembly.dll testdata/net8.0/mock-assembly.dll",
new MockAssemblyExpectedResult("netcore-6.0", "netcore-8.0")));
StandardRunnerTests.Add(new PackageTest(
1, "Net462PlusNet60Test",
"Run mock-assembly under .Net Framework 4.6.2 and .Net 6.0 together",
"testdata/net462/mock-assembly.dll testdata/net6.0/mock-assembly.dll",
new MockAssemblyExpectedResult("net-4.6.2", "netcore-6.0")));
//////////////////////////////////////////////////////////////////////
// ASP.NETCORE TESTS
//////////////////////////////////////////////////////////////////////
AddToBothLists(new PackageTest(
1, "Net60AspNetCoreTest", "Run test using AspNetCore targeting .NET 6.0",
"testdata/net6.0/aspnetcore-test.dll", new ExpectedResult("Passed")
{
Total = 3, Passed = 3, Failed = 0, Warnings = 0, Inconclusive = 0, Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "netcore-6.0") }
}));
AddToBothLists(new PackageTest(
1, "Net80AspNetCoreTest", "Run test using AspNetCore targeting .NET 8.0",
"testdata/net8.0/aspnetcore-test.dll", new ExpectedResult("Passed")
{
Total = 3, Passed = 3, Failed = 0, Warnings = 0, Inconclusive = 0, Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "netcore-8.0") }
}));
//////////////////////////////////////////////////////////////////////
// WINDOWS FORMS TESTS
//////////////////////////////////////////////////////////////////////
AddToBothLists(new PackageTest(
1, "Net60WindowsFormsTest", "Run test using windows forms under .NET 6.0",
"testdata/net6.0-windows/windows-forms-test.dll", new ExpectedResult("Passed")
{
Total = 2, Passed = 2, Failed = 0, Warnings = 0, Inconclusive = 0, Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("windows-forms-test.dll", "netcore-6.0") }
}));
// Runs under Net80 runner but not NetCore
StandardRunnerTests.Add(new PackageTest(
1, "Net80WindowsFormsTest", "Run test using windows forms under .NET 8.0",
"testdata/net8.0-windows/windows-forms-test.dll", new ExpectedResult("Passed")
{
Total = 2, Passed = 2, Failed = 0, Warnings = 0, Inconclusive = 0, Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("windows-forms-test.dll", "netcore-8.0") }
}));
//////////////////////////////////////////////////////////////////////
// WPF TESTS
//////////////////////////////////////////////////////////////////////
AddToBothLists(new PackageTest(
1, "Net60WPFTest", "Run test using WPF under .NET 6.0",
"testdata/net6.0-windows/WpfTest.dll --trace=Debug",
new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-6.0") } }));
AddToBothLists(new PackageTest(
1, "Net80WPFTest", "Run test using WPF under .NET 8.0",
"testdata/net8.0-windows/WpfTest.dll --trace=Debug",
new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-8.0") } }));
//////////////////////////////////////////////////////////////////////
// RUN TESTS USING EACH OF OUR EXTENSIONS
//////////////////////////////////////////////////////////////////////
// NUnit Project Loader Test
StandardRunnerTests.Add(new PackageTest(
1, "NUnitProjectTest",
"Run NUnit project with mock-assembly.dll built for .NET 4.6.2 and 6.0",
"../../NetFXTests.nunit --config=Release --trace=Debug",
new MockAssemblyExpectedResult("net-4.6.2", "netcore-6.0"),
KnownExtensions.NUnitProjectLoader));
// V2 Result Writer Test
AddToBothLists(new PackageTest(
1, "V2ResultWriterTest",
"Run mock-assembly under .NET 6.0 and produce V2 output",
"testdata/net6.0/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2",
new MockAssemblyExpectedResult("netcore-6.0"),
KnownExtensions.NUnitV2ResultWriter));
// VS Project Loader Tests
StandardRunnerTests.Add(new PackageTest(
1, "VSProjectLoaderTest_Project",
"Run mock-assembly using the .csproj file",
"../../src/TestData/mock-assembly/mock-assembly.csproj --config=Release",
new MockAssemblyExpectedResult("net462", "netcore-3.1", "netcore-6.0", "netcore-7.0", "netcore-8.0"),
KnownExtensions.VSProjectLoader));
StandardRunnerTests.Add(new PackageTest(
1, "VSProjectLoaderTest_Solution",
"Run mock-assembly using the .sln file",
"../../src/TestData/TestData.sln --config=Release --trace=Debug",
new ExpectedResult("Failed")
{
Total = 37 * 5,
Passed = 23 * 5,
Failed = 5 * 5,
Warnings = 1 * 5,
Inconclusive = 1 * 5,
Skipped = 7 * 5,
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("mock-assembly.dll", "net-4.6.2"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-3.1"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-6.0"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-7.0"),
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-8.0"),
new ExpectedAssemblyResult("notest-assembly.dll", "net-4.6.2"),
new ExpectedAssemblyResult("notest-assembly.dll", "netcore-3.1"),
new ExpectedAssemblyResult("notest-assembly.dll", "netstandard-2.0"),
new ExpectedAssemblyResult("WpfApp.exe")
}
},
KnownExtensions.VSProjectLoader));
// TeamCity Event Listener Test
StandardRunnerTests.Add(new PackageTest(
1, "TeamCityListenerTest",
"Run mock-assembly with --teamcity enabled",
"testdata/net462/mock-assembly.dll --teamcity",
new MockAssemblyExpectedResult("net-4.6.2"),
KnownExtensions.TeamCityEventListener));
// V2 Framework Driver Tests
StandardRunnerTests.Add(new PackageTest(
1, "V2FrameworkDriverTest",
"Run mock-assembly-v2 using the V2 Driver in process",
"v2-tests/net462/mock-assembly-v2.dll",
new ExpectedResult("Failed")
{
Total = 28,
Passed = 18,
Failed = 5,
Warnings = 0,
Inconclusive = 1,
Skipped = 4,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("mock-assembly-v2.dll", "net-4.6.2") }
},
KnownExtensions.NUnitV2Driver));
StandardRunnerTests.Add(new PackageTest(
1, "V2FrameworkDriverTest",
"Run mock-assembly-v2 using the V2 Driver out of process",
"v2-tests/net462/mock-assembly-v2.dll --list-extensions",
new ExpectedResult("Failed")
{
Total = 28,
Passed = 18,
Failed = 5,
Warnings = 0,
Inconclusive = 1,
Skipped = 4,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("mock-assembly-v2.dll", "net-4.6.2") }
},
KnownExtensions.NUnitV2Driver));
//////////////////////////////////////////////////////////////////////
// SPECIAL CASES
//////////////////////////////////////////////////////////////////////
StandardRunnerTests.Add(new PackageTest(
1, "InvalidTestNameTest_Net462",
"Ensure we handle invalid test names correctly under .NET 4.6.2",
"testdata/net462/InvalidTestNames.dll --trace:Debug",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "net-4.6.2")
}
}));
AddToBothLists(new PackageTest(
1, "InvalidTestNameTest_Net60",
"Ensure we handle invalid test names correctly under .NET 6.0",
"testdata/net6.0/InvalidTestNames.dll --trace:Debug",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-6.0")
}
}));
AddToBothLists(new PackageTest(
1, "InvalidTestNameTest_Net80",
"Ensure we handle invalid test names correctly under .NET 8.0",
"testdata/net8.0/InvalidTestNames.dll --trace:Debug",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-8.0")
}
}));
StandardRunnerTests.Add(new PackageTest(
1, "AppContextBaseDirectory_NET80",
"Test Setting the BaseDirectory to match test assembly location under .NET 8.0",
"testdata/net8.0/AppContextTest.dll",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("AppContextTest.dll", "netcore-8.0") }
}));