-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNUnit3.fsx
More file actions
67 lines (64 loc) · 2.48 KB
/
NUnit3.fsx
File metadata and controls
67 lines (64 loc) · 2.48 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
#r @"packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.ReportGeneratorHelper
open Fake.OpenCoverHelper
open System
open System.Text
let NUnit3Defaults =
let toolname = "nunit3-console.exe"
{ IncludeCategory = ""
ExcludeCategory = ""
ToolPath = findToolFolderInSubPath toolname (currentDirectory @@ "tools" @@ "Nunit")
ToolName = toolname
DontTestInNewThread = false
StopOnError = false
OutputFile = currentDirectory @@ "TestResult.xml"
Out = ""
ErrorOutputFile = ""
WorkingDir = ""
Framework = ""
ProcessModel = DefaultProcessModel
ShowLabels = true
XsltTransformFile = ""
TimeOut = TimeSpan.FromMinutes 5.0
DisableShadowCopy = false
Domain = DefaultDomainModel
ErrorLevel = Error
Fixture = ""}
/// Builds the command line arguments from the given parameter record and the given assemblies.
/// [omit]
let buildNUnitdArgs parameters assemblies =
new StringBuilder()
|> append "--result=nunit2"
|> appendFileNamesIfNotNull assemblies
|> appendIfNotNullOrEmpty parameters.OutputFile "--out="
|> toText
let NUnit3 (setParams : NUnitParams -> NUnitParams) (assemblies : string seq) =
let details = assemblies |> separated ", "
traceStartTask "NUnit" details
let parameters = NUnit3Defaults |> setParams
let assemblies = assemblies |> Seq.toArray
if Array.isEmpty assemblies then failwith "NUnit: cannot run tests (the assembly list is empty)."
let tool = parameters.ToolPath @@ parameters.ToolName
let args = buildNUnitdArgs parameters assemblies
trace (tool + " " + args)
let result =
ExecProcess (fun info ->
info.FileName <- tool
info.WorkingDirectory <- getWorkingDir parameters
info.Arguments <- args) parameters.TimeOut
sendTeamCityNUnitImport parameters.OutputFile
let errorDescription error =
match error with
| OK -> "OK"
| TestsFailed -> sprintf "NUnit test failed (%d)." error
| FatalError x -> sprintf "NUnit test failed. Process finished with exit code %s (%d)." x error
match parameters.ErrorLevel with
| DontFailBuild ->
match result with
| OK | TestsFailed -> traceEndTask "NUnit" details
| _ -> raise (FailedTestsException(errorDescription result))
| Error | FailOnFirstError ->
match result with
| OK -> traceEndTask "NUnit" details
| _ -> raise (FailedTestsException(errorDescription result))