-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmicro.test.suite.au3
More file actions
91 lines (79 loc) · 2.64 KB
/
micro.test.suite.au3
File metadata and controls
91 lines (79 loc) · 2.64 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
Func newTestSuite($suiteName)
Local $oClassObject = _AutoItObject_Class()
$oClassObject.Create()
Local $dicTest = ObjCreate("Scripting.Dictionary")
With $oClassObject
.AddMethod("finish", "finish")
.AddMethod("addTest", "AddTest")
.AddMethod("testPassed","testPassed")
.AddMethod("testFailed","testFailed")
.AddMethod("reportTest","reportTest")
.AddMethod("duration","suiteDuration")
EndWith
With $oClassObject
.AddProperty("_type_", $ELSCOPE_PUBLIC, "TestSuite") ;Object type
.AddProperty("name", $ELSCOPE_PUBLIC, $suiteName)
.AddProperty("ci", $ELSCOPE_PUBLIC, False)
.AddProperty("format", $ELSCOPE_PUBLIC, "html")
.AddProperty("tests", $ELSCOPE_PUBLIC, $dicTest)
.AddProperty("testCount", $ELSCOPE_PUBLIC, 0)
.AddProperty("testsPassed", $ELSCOPE_PUBLIC, 0)
.AddProperty("testsFailed", $ELSCOPE_PUBLIC, 0)
.AddProperty("pass", $ELSCOPE_PUBLIC, True) ;0 Failed - 1 OK
.AddProperty("result", $ELSCOPE_PUBLIC, "Passed")
.AddProperty("beginTime", $ELSCOPE_PUBLIC, _NowCalc())
.AddProperty("endTime", $ELSCOPE_PUBLIC, _NowCalc())
.AddProperty("failFast", $ELSCOPE_PUBLIC, False)
EndWith
Return $oClassObject.Object
EndFunc
Func addTest($this, $test)
$this.testCount = $this.testCount + 1
If $test.pass Then
$this.testPassed()
Else
$this.testFailed()
EndIf
$this.reportTest($test)
$this.tests.Add($this.testCount, $test.TestResult)
EndFunc
Func testPassed($this)
$this.testsPassed = $this.testsPassed + 1
EndFunc
Func testFailed($this)
$this.pass = False
$this.result = "Failed"
$this.testsFailed = $this.testsFailed + 1
If $this.failFast Then
Exit 1
EndIf
EndFunc
Func finish($this)
$this.endTime = _NowCalc()
ConsoleWrite(@CRLF & @CRLF)
If $this.pass Then
Exit 0
Else
Exit 1
EndIf
EndFunc
Func suiteDuration($this)
Return $this.endTime - $this.beginTime
EndFunc
Func reportTest($this, $test)
If $this.ci Then
appveyorAddTest($test.name, $test.testResult, $test.duration())
Else
ConsoleWrite(@CRLF & "(" & $this.testCount & ") " & $test.name & @CRLF)
ConsoleWrite($test.steps & @CRLF)
For $step In $test.steps
If $test.steps.Item($step)[1] Then
ConsoleWrite("+" & @TAB & "PASS" & @TAB & $test.steps.Item($step)[0] & @CRLF)
Else
ConsoleWrite("!" & @TAB & "FAIL" & @TAB & $test.steps.Item($step)[0] & @CRLF)
ConsoleWrite("!" & @TAB & " Expected: " & @TAB & $test.expectedResult & @CRLF)
ConsoleWrite("!" & @TAB & " Received: " & @TAB & $test.receivedResult & @CRLF)
EndIf
Next
EndIf
EndFunc