-
Notifications
You must be signed in to change notification settings - Fork 2
/
JUnit.fs
39 lines (34 loc) · 1.33 KB
/
JUnit.fs
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
module JUnit
open System.Xml
type ValidationResults = {
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: ValidationResults) =
res.ErroredTests.Length + res.FailedTests.Length + res.PassedTests.Length