-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmicro.test.au3
81 lines (68 loc) · 2.41 KB
/
micro.test.au3
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
Func newTest($testName)
$oClassObject = _AutoItObject_Class()
$oClassObject.Create()
$dicSteps = ObjCreate("Scripting.Dictionary")
With $oClassObject
.AddMethod("addStep","addStep")
.AddMethod("countSteps","countSteps")
.AddMethod("assertTrue","assertTrue")
.AddMethod("assertFalse","assertFalse")
.AddMethod("assertEquals","assertEquals")
.AddMethod("assertNotEquals","assertNotEquals")
.AddMethod("stepPassed","stepPassed")
.AddMethod("stepFailed","stepFailed")
.AddMethod("duration","duration")
EndWith
With $oClassObject
.AddProperty("_type_", $ELSCOPE_PUBLIC, "Test") ;Object type
.AddProperty("name", $ELSCOPE_PUBLIC,$testName)
.AddProperty("steps", $ELSCOPE_PUBLIC, $dicSteps) ;Dictionary with test case steps
.AddProperty("stepCount",$ELSCOPE_PRIVATE,0)
.AddProperty("pass",$ELSCOPE_PUBLIC,True)
.AddProperty("testResult",$ELSCOPE_PUBLIC,"Passed") ;0 Failed - 1 OK
.AddProperty("expectedResult",$ELSCOPE_PUBLIC,"")
.AddProperty("recievedResult",$ELSCOPE_PUBLIC,"")
.AddProperty("stepsFailed",$ELSCOPE_PUBLIC,0)
.AddProperty("stepsPassed",$ELSCOPE_PUBLIC,0)
.AddProperty("beginTime",$ELSCOPE_PRIVATE,_NowCalc())
.AddProperty("endTime",$ELSCOPE_PRIVATE,_NowCalc())
EndWith
Return $oClassObject.Object
EndFunc
Func assertTrue($this, $assertText, $assertion)
$this.addStep($assertText, $assertion)
$this.endTime = _NowCalc()
Return $assertion
EndFunc
Func assertFalse($this, $assertText, $falseAssertion)
Return $this.assertTrue($assertText, Not $falseAssertion)
EndFunc
Func assertEquals($this, $assertText, $first, $second)
$this.expectedResult = $second
$this.recievedResult = $first
Return $this.assertTrue($assertText, $first = $second)
EndFunc
Func assertNotEquals($this, $assertText, $first, $second)
Return $this.assertFalse($assertText, $first = $second)
EndFunc
Func addStep($this,$stepText,$assertion)
Local $step[2] = [$stepText,$assertion]
$this.stepCount = $this.stepCount + 1
$this.steps.Add($this.stepCount, $step)
If $assertion Then
$this.stepPassed()
Else
$this.stepFailed()
EndIf
EndFunc
Func stepFailed($this)
$this.pass = False
$this.testResult = "Failed"
$this.stepsFailed = $this.stepsFailed + 1
EndFunc
Func stepPassed($this)
$this.stepsPassed = $this.stepsPassed + 1
EndFunc
Func duration($this)
Return $this.endTime - $this.beginTime
EndFunc