forked from nunit/nunit3-vs-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacceptance.cake
47 lines (37 loc) · 1.68 KB
/
acceptance.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
#load lib.cake
using System.Xml.Linq;
const string acceptanceTestConfiguration = "Release";
Task("Acceptance")
.IsDependentOn("Build")
.IsDependentOn("PackageNuGet")
.Description("Ensures that known project configurations can use the produced NuGet package to restore, build, and run tests.")
.Does(() =>
{
DeleteDirectoryRobust(@"tests\Isolated package cache\nunit3testadapter");
using (var tempDirectory = new TempDirectory())
{
BuildAndVerifySinglePassingTest("Simple", "net45", "netcoreapp1.0");
BuildAndVerifySinglePassingTest("Referencing Mono.Cecil", "net45", "netcoreapp1.0");
BuildAndVerifySinglePassingTest("Referencing Mono.Cecil 0.10.0", "net45", "netcoreapp1.0");
void BuildAndVerifySinglePassingTest(string projectName, params string[] targetFrameworks)
{
var project = NewProjectFixture(Directory($@"tests\{projectName}"), acceptanceTestConfiguration, tempDirectory);
project.Build(packageVersion);
foreach (var targetFramework in targetFrameworks)
{
VerifySinglePassingTest(project.Test(targetFramework));
}
}
}
});
void VerifySinglePassingTest(FilePath trxPath)
{
var ns = (XNamespace)"http://microsoft.com/schemas/VisualStudio/TeamTest/2010";
var counters = XElement.Load(trxPath.FullPath)
.Element(ns + "ResultSummary")
.Element(ns + "Counters");
if (counters.Attribute("total").Value != "1" || counters.Attribute("passed").Value != "1")
{
throw new Exception("Expected a single passing test result.");
}
}