-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-tests.cake
More file actions
724 lines (645 loc) · 27.6 KB
/
Copy pathpackage-tests.cake
File metadata and controls
724 lines (645 loc) · 27.6 KB
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
// 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")
{
Description = "Run mock-assembly.dll under .NET 4.6.2",
Arguments = "testdata/net462/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2")
});
// This works under the .NET 8.0 runner but the test is minimal
AddToBothLists(new PackageTest(1, "Net90Test")
{
Description = "Run mock-assembly.dll under .NET 9.0",
Arguments = "testdata/net9.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("netcore-9.0")
});
AddToBothLists(new PackageTest(1, "Net80Test")
{
Description = "Run mock-assembly.dll under .NET 8.0",
Arguments = "testdata/net8.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("netcore-8.0")
});
AddToBothLists(new PackageTest(1, "Net70Test")
{
Description = "Run mock-assembly.dll under .NET 7.0",
Arguments = "testdata/net7.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("netcore-7.0")
});
AddToBothLists(new PackageTest(1, "Net60Test")
{
Description = "Run mock-assembly.dll under .NET 6.0",
Arguments = "testdata/net6.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("netcore-6.0")
});
AddToBothLists(new PackageTest(1, "NetCore31Test")
{
Description = "Run mock-assembly.dll under .NET Core 3.1",
Arguments = "testdata/netcoreapp3.1/mock-assembly.dll",
ExpectedResult = 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")
{
Description = "Run mock-assembly-x86.dll under .NET 4.6.2",
Arguments = "testdata/net462/mock-assembly-x86.dll",
ExpectedResult = new MockAssemblyX86ExpectedResult("net-4.6.2")
});
if (dotnetX86Available)
{
StandardRunnerTests.Add(new PackageTest(1, "Net80X86Test")
{
Description = "Run mock-assembly-x86.dll under .NET 8.0",
Arguments = "testdata/net8.0/mock-assembly-x86.dll",
ExpectedResult = new MockAssemblyX86ExpectedResult("netcore-8.0")
});
StandardRunnerTests.Add(new PackageTest(1, "Net60X86Test")
{
Description = "Run mock-assembly-x86.dll under .NET 6.0",
Arguments = "testdata/net6.0/mock-assembly-x86.dll",
ExpectedResult = new MockAssemblyX86ExpectedResult("netcore-6.0")
});
// TODO: Make tests run on all build platforms
if (!BuildSystem.IsRunningOnGitHubActions)
{
StandardRunnerTests.Add(new PackageTest(1, "Net90X86Test")
{
Description = "Run mock-assembly-x86.dll under .NET 9.0",
Arguments = "testdata/net9.0/mock-assembly-x86.dll",
ExpectedResult = new MockAssemblyX86ExpectedResult("netcore-9.0")
});
StandardRunnerTests.Add(new PackageTest(1, "Net70X86Test")
{
Description = "Run mock-assembly-x86.dll under .NET 7.0",
Arguments = "testdata/net7.0/mock-assembly-x86.dll",
ExpectedResult = new MockAssemblyX86ExpectedResult("netcore-7.0")
});
StandardRunnerTests.Add(new PackageTest(1, "NetCore31X86Test")
{
Description = "Run mock-assembly-x86.dll under .NET Core 3.1",
Arguments = "testdata/netcoreapp3.1/mock-assembly-x86.dll",
ExpectedResult = new MockAssemblyX86ExpectedResult("netcore-3.1")
});
}
}
//////////////////////////////////////////////////////////////////////
// RUN MULTIPLE COPIES OF MOCK-ASSEMBLY
//////////////////////////////////////////////////////////////////////
// TODO: Remove agents arg when current bug is fixed.
StandardRunnerTests.Add(new PackageTest(1, "Net462PlusNet462Test")
{
Description = "Run two copies of mock-assembly together",
Arguments = "testdata/net462/mock-assembly.dll testdata/net462/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2", "net-4.6.2")
});
StandardRunnerTests.Add(new PackageTest(1, "Net60PlusNet80Test")
{
Description = "Run mock-assembly under .NET6.0, 8.0 and 9.0 together",
Arguments = "testdata/net6.0/mock-assembly.dll testdata/net8.0/mock-assembly.dll testdata/net9.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("netcore-6.0", "netcore-8.0", "netcore-9.0")
});
StandardRunnerTests.Add(new PackageTest(1, "Net462PlusNet60Test")
{
Description = "Run mock-assembly under .Net Framework 4.6.2 and .Net 6.0 together",
Arguments = "testdata/net462/mock-assembly.dll testdata/net6.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2", "netcore-6.0")
});
//////////////////////////////////////////////////////////////////////
// TEST WITH MISSING AND INVALID FILES
//////////////////////////////////////////////////////////////////////
StandardRunnerTests.Add(new PackageTest(1, "NonExistentTest")
{
Description = "Run non-existent unknown.dll",
Arguments = "unknown.dll",
ExpectedResult = new ExpectedResult("Failed:Invalid")
{
Assemblies = new[] { new ExpectedAssemblyResult("unknown.dll") }
}
});
StandardRunnerTests.Add(new PackageTest(1, "InValidFileTypeTest")
{
Description = "Run file with an invalid file type",
Arguments = "testdata/net462/mock-assembly.pdb",
ExpectedResult = new ExpectedResult("Failed:Invalid")
{
Assemblies = new[] { new ExpectedAssemblyResult("mock-assembly.pdb") }
}
});
StandardRunnerTests.Add(new PackageTest(1, "Net462PlusNonExistentTest")
{
Description = "Run mock-assembly and non-existent unknown.dll together",
Arguments = "testdata/net462/mock-assembly.dll unknown.dll",
ExpectedResult = new ExpectedResult("Failed:Invalid")
{
Assemblies = new[] { new ExpectedAssemblyResult("mock-assembly.dll"), new ExpectedAssemblyResult("unknown.dll") }
}
});
//////////////////////////////////////////////////////////////////////
// TEST OLDER VERSIONS OF NUNIT SWITCHING API IF NEEDED
//////////////////////////////////////////////////////////////////////
StandardRunnerTests.Add(new PackageTest(1, "NUnit30Test")
{
Description = "Run a test under NUnit 3.0 using 2009 API",
Arguments = "testdata/NUnit3.0/net462/NUnit3.0.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.0.dll", "net462") }
}
});
StandardRunnerTests.Add(new PackageTest(1, "NUnit301Test")
{
Description = "Run a test under NUnit 3.0.1 using 2009 API",
Arguments = "testdata/NUnit3.0.1/net462/NUnit3.0.1.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.0.1.dll", "net462") }
}
});
StandardRunnerTests.Add(new PackageTest(1, "NUnit32Test")
{
Description = "Run a test under NUnit 3.2 using 20018 API",
Arguments = "testdata/NUnit3.2/net462/NUnit3.2.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.2.dll", "net462") }
}
});
StandardRunnerTests.Add(new PackageTest(1, "NUnit310Test")
{
Description = "Run a test under NUnit 3.10 using 2018 API",
Arguments = "testdata/NUnit3.10/net462/NUnit3.10.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new[] { new ExpectedAssemblyResult("NUnit3.10.dll", "net462") }
}
});
//////////////////////////////////////////////////////////////////////
// ASP.NETCORE TESTS
//////////////////////////////////////////////////////////////////////
AddToBothLists(new PackageTest(1, "Net60AspNetCoreTest")
{
Description = "Run test using AspNetCore targeting .NET 6.0",
Arguments = "testdata/net6.0/aspnetcore-test.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Total = 2,
Passed = 2,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "netcore-6.0") }
}
});
AddToBothLists(new PackageTest(1, "Net80AspNetCoreTest")
{
Description = "Run test using AspNetCore targeting .NET 8.0",
Arguments = "testdata/net8.0/aspnetcore-test.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Total = 2,
Passed = 2,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "netcore-8.0") }
}
});
// This works under the .NET 8.0 runner but the test is minimal
AddToBothLists(new PackageTest(1, "Net90AspNetCoreTest")
{
Description = "Run test using AspNetCore targeting .NET 9.0",
Arguments = "testdata/net9.0/aspnetcore-test.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Total = 2,
Passed = 2,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "netcore-9.0") }
}
});
//////////////////////////////////////////////////////////////////////
// WINDOWS FORMS TESTS
//////////////////////////////////////////////////////////////////////
AddToBothLists(new PackageTest(1, "Net60WindowsFormsTest")
{
Description = "Run test using windows forms under .NET 6.0",
Arguments = "testdata/net6.0-windows/windows-test.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Total = 2,
Passed = 2,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("windows-test.dll", "netcore-6.0") }
}
});
AddToBothLists(new PackageTest(1, "Net80WindowsFormsTest")
{
Description = "Run test using windows forms under .NET 8.0",
Arguments = "testdata/net8.0-windows/windows-test.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Total = 2,
Passed = 2,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("windows-test.dll", "netcore-8.0") }
}
});
// This won't work under the .NET 8.0 runner
StandardRunnerTests.Add(new PackageTest(1, "Net90WindowsFormsTest")
{
Description = "Run test using windows forms under .NET 9.0",
Arguments = "testdata/net9.0-windows/windows-test.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Total = 2,
Passed = 2,
Failed = 0,
Warnings = 0,
Inconclusive = 0,
Skipped = 0,
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("windows-test.dll", "netcore-9.0") }
}
});
//////////////////////////////////////////////////////////////////////
// WPF TESTS
//////////////////////////////////////////////////////////////////////
AddToBothLists(new PackageTest(1, "Net60WPFTest")
{
Description = "Run test using WPF under .NET 6.0",
Arguments = "testdata/net6.0-windows/WpfTest.dll",
ExpectedResult = new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-6.0") } }
});
AddToBothLists(new PackageTest(1, "Net80WPFTest")
{
Description = "Run test using WPF under .NET 8.0",
Arguments = "testdata/net8.0-windows/WpfTest.dll",
ExpectedResult = new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-8.0") } }
});
// This won't work under the .NET 8.0 runner
StandardRunnerTests.Add(new PackageTest(1, "Net90WPFTest")
{
Description = "Run test using WPF under .NET 9.0",
Arguments = "testdata/net9.0-windows/WpfTest.dll",
ExpectedResult = new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-9.0") } }
});
//////////////////////////////////////////////////////////////////////
// TESTS OF EXTENSION LISTING
//////////////////////////////////////////////////////////////////////
StandardRunnerTests.Add(new PackageTest(1, "NoExtensionsInstalled")
{
Description = "List Extensions shows only our agent launchers",
Arguments = "--list-extensions",
ExpectedOutput = new[] { Contains("Extension: NUnit.Engine.Agents.Net80AgentLauncher", exactly: 1) }
});
NetCoreRunnerTests.Add(new PackageTest(1, "NoExtensionsInstalled")
{
Description = "List Extensions shows none installed",
Arguments = "--list-extensions",
ExpectedOutput = new[] { DoesNotContain("Extension:") }
});
StandardRunnerTests.Add(new PackageTest(1, "ExtensionsInstalledFromAddedDirectory")
{
Description = "List Extensions shows extension from added directory",
Arguments = "--extensionDirectory fakes/net462 --list-extensions",
ExpectedOutput = new[] { Contains("Extension:", exactly: 5) }
});
NetCoreRunnerTests.Add(new PackageTest(1, "ExtensionsInstalledFromAddedDirectory")
{
Description = "List Extensions shows extension from added directory",
Arguments = "--extensionDirectory fakes/netstandard2.0 --list-extensions",
ExpectedOutput = new[] { Contains("Extension:", exactly: 5) }
});
AddToBothLists(new PackageTest(1, "SpecificExtensionInstalled")
{
Description = "List Extensions shows V2ResultWriter if we include it as needed",
Arguments = "--list-extensions",
ExpectedOutput = new[] { Contains("nunit-v2-result-writer.dll", exactly: 1) },
ExtensionsNeeded = new[] { KnownExtensions.NUnitV2ResultWriter }
});
//////////////////////////////////////////////////////////////////////
// TEST OF ASSEMBLY RESOLUTION STATISTICS
//////////////////////////////////////////////////////////////////////
// TODO: Standard runner tests will not work until agents are updated.
//StandardRunnerTests.Add(new PackageTest(1, "ListResolutionStatistics_Explore")
//{
// Description = "Display Assembly resolution statistics with Explore output",
// // TODO: Should either fix recipe to detect alternate name in spec and map it to the
// // work directory or fix console runner to use work directory in this situation.
// Arguments = "testdata/net8.0-windows/windows-test.dll --explore:../../package/results/nuget/NUnit.ConsoleRunner/ListResolutionStatistics_Explore/TestResult.xml --list-resolution-stats",
// ExpectedResult = new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("windows-test.dll", "netcore-8.0") } }
// //ExpectedOutput = new[] {
// // Contains("Assembly Resolution Statistics"),
// // Contains("windows-test.dll"),
// // Contains("Not Available")
//});
StandardRunnerTests.Add(new PackageTest(1, "ListResolutionStatistics_Run")
{
Description = "Display Assembly resolution statistics with Run output",
Arguments = "testdata/net8.0-windows/windows-test.dll --list-resolution-stats",
ExpectedResult = new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("windows-test.dll", "netcore-8.0") } }
//ExpectedOutput = new[] {
// Contains("Assembly Resolution Statistics"),
// Contains("windows-test.dll"),
// Contains("Not Available")
});
NetCoreRunnerTests.Add(new PackageTest(1, "ListResolutionStatistics_Explore")
{
Description = "Display Assembly resolution statistics with Explore output",
Arguments = "testdata/net8.0-windows/windows-test.dll --explore:LoadResult.xml --list-resolution-stats",
ExpectedOutput = new[] {
Contains("Assembly Resolution Statistics"),
Contains("windows-test.dll"),
// Has an entry for each strategy - counts may vary
Contains("WindowsDesktopStrategy"),
Contains("TrustedPlatformAssembliesStrategy"),
Contains("RuntimeLibrariesStrategy"),
Contains("AspNetCoreStrategy")
}
});
NetCoreRunnerTests.Add(new PackageTest(1, "ListResolutionStatistics_Run")
{
Description = "Display Assembly resolution statistics with Run output",
Arguments = "testdata/net8.0-windows/windows-test.dll --list-resolution-stats",
ExpectedOutput = new[] {
Contains("Assembly Resolution Statistics"),
Contains("windows-test.dll"),
// Has an entry for each strategy - counts may vary
Contains("WindowsDesktopStrategy"),
Contains("TrustedPlatformAssembliesStrategy"),
Contains("RuntimeLibrariesStrategy"),
Contains("AspNetCoreStrategy")
}
});
//////////////////////////////////////////////////////////////////////
// RUN TESTS USING EACH OF OUR EXTENSIONS
//////////////////////////////////////////////////////////////////////
//StandardRunnerTests.Add(new PackageTest(1, "FakeEventListenerTest")
//{
// Description = "Test that event listener gets all reports",
// Arguments = "testdata/net462/mock-assembly.dll --extensionDirectory ../../src/TestData/FakeExtensions",
// ExpectedResult = new MockAssemblyExpectedResult("netcore-4.6.2")
//});
// TODO: Add back extension tests after latest changes to ExtensionManager
// are ported. Most extensions will require an update to work under V4.
//NUnit Project Loader Tests
StandardRunnerTests.Add(new PackageTest(1, "NUnitProjectTest")
{
Description = "Run NUnit project with mock-assembly.dll built for .NET 4.6.2 and 6.0",
Arguments = "../../MixedTests.nunit --config=Release",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2", "net-6.0"),
ExtensionsNeeded = new[] { KnownExtensions.NUnitProjectLoader }
});
//NetCoreRunnerTests.Add(new PackageTest(1, "NUnitProjectTest")
//{
// Description = "Run NUnit project with mock-assembly.dll built for .NET 6.0 and 8.0",
// Arguments = "../../NetCoreTests.nunit --config=Release",
// ExpectedResult = new MockAssemblyExpectedResult("netcore-6.0", "netcore-8.0"),
// ExtensionsNeeded = new[] { KnownExtensions.NUnitProjectLoader }
//});
// V2 Result Writer Tests
StandardRunnerTests.Add(new PackageTest(1, "V2ResultWriterTest_Net462")
{
Description = "Run mock-assembly under .NET 4.6.2 and produce V2 output",
Arguments = "testdata/net462/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2"),
// TODO: Check that V2 result file was created
ExtensionsNeeded = new[] { KnownExtensions.NUnitV2ResultWriter }
});
AddToBothLists(new PackageTest(1, "V2ResultWriterTest_Net60")
{
Description = "Run mock-assembly under .NET 6.0 and produce V2 output",
Arguments = "testdata/net6.0/mock-assembly.dll --result=TestResult.xml --result=NUnit2TestResult.xml;format=nunit2",
ExpectedResult = new MockAssemblyExpectedResult("netcore-6.0"),
// TODO: Check that V2 result file was created
ExtensionsNeeded = new[] { KnownExtensions.NUnitV2ResultWriter }
});
//// VS Project Loader Tests
//StandardRunnerTests.Add(new PackageTest(1, "VSProjectLoaderTest_Project")
//{
// Description = "Run mock-assembly using the .csproj file",
// Arguments = "../../src/TestData/mock-assembly/mock-assembly.csproj --config=Release",
// ExpectedResult = new MockAssemblyExpectedResult("net462", "netcore-3.1", "netcore-6.0", "netcore-7.0", "netcore-8.0"),
// ExtensionsNeeded = new[] { Extensions.VSProjectLoader }
//});
//StandardRunnerTests.Add(new PackageTest(1, "VSProjectLoaderTest_Solution")
//{
// Description = "Run mock-assembly using the .sln file",
// Arguments = "../../src/TestData/TestData.sln --config=Release",
// ExpectedResult = 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")
// }
// },
// ExtensionsNeeded = new[] { Extensions.VSProjectLoader }
//});
// TeamCity Event Listener Test
StandardRunnerTests.Add(new PackageTest(1, "TeamCityListenerTest")
{
Description = "Run mock-assembly with --teamcity enabled",
Arguments = "testdata/net462/mock-assembly.dll --enable NUnit.Engine.Listeners.TeamCityEventListener",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2"),
ExtensionsNeeded = new[] { KnownExtensions.TeamCityEventListener }
});
//// V2 Framework Driver Tests
//StandardRunnerTests.Add(new PackageTest(1, "V2FrameworkDriverTest")
//{
// Description = "Run mock-assembly-v2 using the V2 Driver in process",
// Arguments = "v2-tests/net462/mock-assembly-v2.dll",
// ExpectedResult = 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") }
// },
// ExtensionsNeeded = new[] { Extensions.NUnitV2Driver }
//});
//StandardRunnerTests.Add(new PackageTest(1, "V2FrameworkDriverTest")
//{
// Description = "Run mock-assembly-v2 using the V2 Driver out of process",
// Arguments = "v2-tests/net462/mock-assembly-v2.dll --list-extensions",
// ExpectedResult = 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") }
// },
// ExtensionsNeeded = new[] { Extensions.NUnitV2Driver }
//});
//////////////////////////////////////////////////////////////////////
// SPECIAL CASES
//////////////////////////////////////////////////////////////////////
StandardRunnerTests.Add(new PackageTest(1, "InvalidTestNameTest_Net462")
{
Description = "Ensure we handle invalid test names correctly under .NET 4.6.2",
Arguments = "testdata/net462/InvalidTestNames.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "net-4.6.2")
}
}
});
AddToBothLists(new PackageTest(1, "InvalidTestNameTest_Net60")
{
Description = "Ensure we handle invalid test names correctly under .NET 6.0",
Arguments = "testdata/net6.0/InvalidTestNames.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-6.0")
}
}
});
AddToBothLists(new PackageTest(1, "InvalidTestNameTest_Net80")
{
Description = "Ensure we handle invalid test names correctly under .NET 8.0",
Arguments = "testdata/net8.0/InvalidTestNames.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-8.0")
}
}
});
AddToBothLists(new PackageTest(1, "AppContextBaseDirectory_NET80")
{
Description = "Test Setting the BaseDirectory to match test assembly location under .NET 8.0",
Arguments = "testdata/net8.0/AppContextTest.dll",
ExpectedResult = new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("AppContextTest.dll", "netcore-8.0") }
}
});
AddToBothLists(new PackageTest(1, "UnmanagedAssemblyTest")
{
Description = "Attempt to run an unmanaged assembly fails gracefully",
Arguments = "../../src/TestData/native-assembly/NativeTests.dll",
ExpectedResult = new ExpectedResult("Failed:Invalid")
{
Assemblies = new ExpectedAssemblyResult[] { new ExpectedAssemblyResult("NativeTests.dll", "net-4.6.2") }
}
});
// NOTE: Tests for NUnit.Engine and NUnit.Agent.Core here are quite limited. At this
// point, the main purpose they serve is to demonstrate that we are ABLE to run
// the tests without using the console runner.
//
// That's because multiple packages are created by this build script and these tests
// really just repetitions of tests we perform for the console runner package.
// When either of these packages is moved to a separate repository, the tests will
// become more meaningful and will then be expanded.
// Tests for NUnit.Engine package
var EngineTests = new List<PackageTest>()
{
new PackageTest(1, "Net462AgentTest")
{
Description = "Run mock-assembly.dll under .NET 4.6.2",
Arguments = "testdata/net462/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2")
},
new PackageTest(1, "Net462X86AgentTest")
{
Description = "Run mock-assembly-x86.dll under .NET 4.6.2",
Arguments = "testdata/net462/mock-assembly-x86.dll --x86",
ExpectedResult = new MockAssemblyX86ExpectedResult("net-4.6.2")
},
new PackageTest(1, "Net80AgentTest")
{
Description = "Run mock-assembly.dll under .NET 8.0",
Arguments = "testdata/net8.0/mock-assembly.dll",
ExpectedResult = new MockAssemblyExpectedResult("netcore-8.0")
}
};
// Tests for NUnit.Agent.Core package
var AgentCoreTests = new List<PackageTest>()
{
new PackageTest(1, "Net462AgentTest")
{
Description = "Run mock-assembly.dll under .NET 4.6.2",
Arguments = "testdata/net462/mock-assembly.dll --trace:Debug",
ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2")
},
new PackageTest(1, "Net80AgentTest")
{
Description = "Run mock-assembly.dll under .NET 8.0",
Arguments = "testdata/net8.0/mock-assembly.dll --trace:Debug",
ExpectedResult = new MockAssemblyExpectedResult("netcore-8.0")
}
};