forked from AutoItMicro/MicroUnitTestingFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicro.test.au3
More file actions
64 lines (54 loc) · 1.84 KB
/
micro.test.au3
File metadata and controls
64 lines (54 loc) · 1.84 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
Func _test_($testName)
$oClassObject = _AutoItObject_Class()
$oClassObject.Create()
$dicSteps = ObjCreate("Scripting.Dictionary")
With $oClassObject
.AddMethod("addStep","addStep")
.AddMethod("countSteps","countSteps")
.AddMethod("assertTrue","assertTrue")
.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("testStepsFailed",$ELSCOPE_PUBLIC,0)
.AddProperty("testStepsPassed",$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()
EndFunc
Func assertFalse($this, $assertText, $falseAssertion)
$this.assertTrue($assertText,Not $falseAssertion)
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.testStepFailed = $this.testStepFailed + 1
EndFunc
Func stepPassed($this)
$this.testStepPassed = $this.testStepPassed + 1
EndFunc
Func duration($this)
Return $this.endTime - $this.beginTime
EndFunc