-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTestSuite.prg
122 lines (74 loc) · 2.61 KB
/
TestSuite.prg
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//-- copyright
// hbunit is a unit-testing framework for the Harbour language.
//
// Copyright (C) 2014 Enderson maia <endersonmaia _at_ gmail _dot_ com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// See COPYRIGHT for more details.
//++
#include "hbunit.ch"
CLASS TestSuite FROM TestBase
DATA aTests
DATA aMethods
DATA aCategories
METHOD New() CONSTRUCTOR
METHOD Run()
METHOD End()
METHOD addTest( oTest )
METHOD setCategories( uCategories )
METHOD isInCategories( aTestCategories )
METHOD setMethods( uMethods )
ENDCLASS
//---------------------------------------------------------------------------//
METHOD New() CLASS TestSuite
::Super:New()
::aTests := {}
::aCategories := { "all" }
::aMethods := {}
RETURN ( self )
//---------------------------------------------------------------------------//
METHOD Run() CLASS TestSuite
aeval( ::aTests, {|oTest| if( ::isInCategories( oTest:aCategories ), oTest:Run(), ) } )
RETURN ( ::oResult )
//---------------------------------------------------------------------------//
METHOD End() CLASS TestSuite
aeval( ::aTests, {|oTest| oTest:End() } )
RETURN ( nil )
//---------------------------------------------------------------------------//
METHOD addTest( oTest ) CLASS TestSuite
RETURN ( aadd( ::aTests, oTest ) )
//---------------------------------------------------------------------------//
METHOD setCategories( uCategories ) CLASS TestSuite
if hb_ischar( uCategories )
aadd( ::aCategories, uCategories )
end if
if hb_isarray( uCategories )
::aCategories := uCategories
end if
RETURN ( ::aCategories )
//---------------------------------------------------------------------------//
METHOD isInCategories( aTestCategories ) CLASS TestSuite
local cTestCategory
local cSuiteCategory
for each cTestCategory in aTestCategories
for each cSuiteCategory in ::aCategories
if cTestCategory == cSuiteCategory
RETURN ( .t. )
end if
next
next
RETURN ( .f. )
//---------------------------------------------------------------------------//
METHOD setMethods( uMethods ) CLASS TestSuite
if hb_ischar( uMethods )
aadd( ::aMethods, uMethods )
end if
if hb_isarray( uMethods )
::aMethods := uMethods
end if
RETURN ( ::aMethods )
//---------------------------------------------------------------------------//