Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
TestingFramework.c
Go to the documentation of this file.
1
8
73
78
79
//-----------------------------------------------------------------------------
81
class
Test
82
{
83
typename
Suite;
84
85
int
TimeoutS;
86
int
TimeoutMs;
87
int
MaxAttempts;
88
90
void
Test(
string
suiteStr =
""
,
typename
suite =
void
,
int
timeoutS = 0,
int
timeoutMs = 0,
int
maxAttempts = 1)
91
{
92
if
(suite !=
void
)
93
{
94
Suite = suite;
95
}
96
else
97
{
98
PrintFormat
(
99
"Test referring to TestSuite using string '%1' instead of typename. This is deprecated and should be replaced by explicitly setting passing 'suite' parameter"
,
100
suiteStr, level:
LogLevel
.WARNING
101
);
102
Suite = suiteStr.ToType();
103
}
104
TimeoutS = timeoutS;
105
TimeoutMs = timeoutMs;
106
MaxAttempts = maxAttempts;
107
}
108
}
109
110
//-----------------------------------------------------------------------------
112
typedef
TestStage
EStage
;
113
114
//-----------------------------------------------------------------------------
116
class
TestStep
117
{
118
TestStage
Stage;
119
int
TimeoutS;
120
int
TimeoutMs;
121
122
void
TestStep(
TestStage
stage =
TestStage
.Main,
int
timeoutS = 0,
int
timeoutMs = 0)
123
{
124
Stage = stage;
125
TimeoutS = timeoutS;
126
TimeoutMs = timeoutMs;
127
}
128
}
129
131
typedef
TestStep
Step
;
132
136
137
#ifdef DOXYGEN
138
139
//-----------------------------------------------------------------------------
141
class
TestBoolResult :
TestResultBase
142
{
143
bool
Value;
144
145
void
TestBoolResult(
bool
val) { Value = val; }
146
147
override
bool
Failure() {
return
!Value; }
148
149
override
string
FailureText()
150
{
151
// junit kind of error report. (simple)
152
return
"<failure type=\"TestBoolResult\" message=\"Failed.\" />"
;
153
}
154
}
155
156
//-----------------------------------------------------------------------------
157
class
MyTestSuite :
TestSuite
158
{
159
private
int
m_Count;
160
161
[TestStep(
TestStage
.Setup)]
162
void
Prep()
163
{
164
Print
(
"MyTestSuite.Prep"
);
165
m_Count = 3;
166
}
167
168
[TestStep(
TestStage
.Setup)]
169
bool
Count
()
170
{
171
--m_Count;
172
Print
(
"MyTestSuite.Count: "
+ m_Count);
173
return
m_Count == 0;
174
}
175
176
[TestStep(
TestStage
.TearDown)]
177
bool
CountUp()
178
{
179
++m_Count;
180
Print
(
"MyTestSuite.CountUp: "
+ m_Count);
181
return
m_Count == 10;
182
}
183
}
184
185
//-----------------------------------------------------------------------------
187
[
Test
(suite: MyTestSuite, timeoutS: 2, timeoutMs: 250)]
188
class
MyAsyncTest :
TestBase
189
{
190
private
int
m_Count;
191
192
// Simple blocking initialization.
193
[TestStep(
TestStage
.Setup)]
194
void
Init
()
195
{
196
Print
(
"MyAsyncTest.Init"
);
197
m_Count = 10;
198
}
199
200
// Async test which is waiting for result for several frames.
201
[TestStep(
TestStage
.Main)]
202
bool
Poll()
203
{
204
Print
(
"MyAsyncTest.Poll: "
+ m_Count);
205
206
if
(m_Count == 0)
207
{
208
Print
(
"MyAsyncTest.Poll Result"
);
209
SetResult(
new
TestBoolResult(
false
));
210
m_Count = 3;
211
return
true
;
212
}
213
214
Print
(
"MyAsyncTest.Poll Progress"
);
215
216
m_Count--;
217
return
false
;
218
}
219
220
// Finalization process waiting for result for several frames.
221
[TestStep(
TestStage
.TearDown)]
222
bool
Finalizing()
223
{
224
Print
(
"MyAsyncTest.Finalizing: "
+ m_Count);
225
if
(m_Count == 0)
226
{
227
Print
(
"MyAsyncTest.Finalizing Done"
);
228
return
true
;
229
}
230
231
Print
(
"MyAsyncTest.Finalizing Progress"
);
232
m_Count--;
233
return
false
;
234
}
235
236
// Simple blocking finalization call.
237
[TestStep(
TestStage
.TearDown)]
238
void
Finalized()
239
{
240
Print
(
"MyAsyncTest.Finalized"
);
241
}
242
}
244
245
#endif
Init
override void Init()
Definition
CharacterCameraHandlerComponent.c:40
TestBase
Test base class.
Definition
TestBase.c:14
Test
Attribute used for tests annotation and assignment to Suites.
Definition
TestingFramework.c:82
TestResultBase
Definition
TestResultBase.c:17
TestStep
Attribute which marks a method as part of the testing process.
Definition
TestingFramework.c:117
TestSuite
Collection of tests. Provides API for environment preparation.
Definition
TestSuite.c:14
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
PrintFormat
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
Step
class TestStep Step
TestStage
TestStage
Stage definition used in conjunction with TestStep attribute.
Definition
TestStage.c:14
EStage
class Test EStage
Count
TypeID handle64 Count()
scripts
GameLib
tests
TestingFramework.c
Generated by
1.17.0