-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrationTests_script.fsx
93 lines (75 loc) · 3.27 KB
/
integrationTests_script.fsx
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
#r "nuget: Xunit"
#r "nuget: Fake.DotNet.Cli"
open Xunit
open Fake.Core
open System.Xml
let runTool (tool: string) (args: string []) (dir:string) =
CreateProcess.fromRawCommand tool args
|> CreateProcess.withWorkingDirectory dir
|> CreateProcess.redirectOutput
|> Proc.run
//let result = runTool "dotnet" [|"fsi"; @"C:\Repos\nfdi4plants\arc-validation-packages\validation_packages\invenio\[email protected]"|] @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\testARC_empty\"
let result = runTool "dotnet" [|"fsi"; @"C:\Repos\nfdi4plants\arc-validation-packages\validation_packages\invenio\[email protected]"|] @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\testARC_emptyContactsColumn\"
type JUnitResults = {
PassedTests: string list
FailedTests: string list
ErroredTests: string list
} with
static member fromJUnitFile (path:string) =
let doc = new XmlDocument()
doc.Load(path)
let suite = doc.SelectNodes("/testsuites/testsuite[@name='arc-validate']").Item(0);
let testCases = suite.SelectNodes("testcase") |> Seq.cast<XmlNode>
{
PassedTests =
testCases
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count = 0)
|> Seq.map (fun tc -> tc.Attributes.["name"].Value)
|> Seq.toList
|> List.sort
FailedTests =
testCases
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count > 0)
|> Seq.map (fun tc -> tc.Attributes.["name"].Value)
|> Seq.toList
|> List.sort
ErroredTests =
testCases
|> Seq.filter (fun tc -> tc.SelectNodes("error").Count > 0)
|> Seq.map (fun tc -> tc.Attributes.["name"].Value)
|> Seq.toList
|> List.sort
}
static member getTotalTestCount (res : JUnitResults) =
res.ErroredTests.Length + res.FailedTests.Length + res.PassedTests.Length
let jUnitRes = JUnitResults.fromJUnitFile @"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\ArcPrototype\.arc-validate-results\[email protected]\validation_report.xml"
null = null
let doc = new XmlDocument()
doc.Load(@"C:\Repos\nfdi4plants\arc-validation-packages\tests\fixtures\ArcPrototype\.arc-validate-results\[email protected]\validation_report.xml")
let suite =
doc.SelectNodes("/testsuites/testsuite[@name='arc-validate']").Item(0)
|> fun r ->
if isNull r then
doc.SelectNodes("/testsuites/testsuite[@name='fsi']").Item(0)
else r
let testCases = suite.SelectNodes("testcase") |> Seq.cast<XmlNode>
{
PassedTests =
testCases
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count = 0)
|> Seq.map (fun tc -> tc.Attributes.["name"].Value)
|> Seq.toList
|> List.sort
FailedTests =
testCases
|> Seq.filter (fun tc -> tc.SelectNodes("failure").Count > 0)
|> Seq.map (fun tc -> tc.Attributes.["name"].Value)
|> Seq.toList
|> List.sort
ErroredTests =
testCases
|> Seq.filter (fun tc -> tc.SelectNodes("error").Count > 0)
|> Seq.map (fun tc -> tc.Attributes.["name"].Value)
|> Seq.toList
|> List.sort
}