DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
TestingFramework.c
См. документацию.
1
93
94//-----------------------------------------------------------------------------
96class Test
97{
98 string Suite;
99
103
105 void Test(string suite, int timeoutS = 0, int timeoutMs = 0, int sortOrder = 0)
106 {
107 Suite = suite;
108 TimeoutS = timeoutS;
109 TimeoutMs = timeoutMs;
110 SortOrder = sortOrder;
111 }
112}
113
114//-----------------------------------------------------------------------------
116enum EStage
117{
120 TearDown
121}
122
123//-----------------------------------------------------------------------------
125class Step
126{
127 EStage Stage;
128
129 void Step(EStage stage = EStage.Main)
130 {
131 Stage = stage;
132 }
133}
134
135//-----------------------------------------------------------------------------
138{
141 proto native static bool Run();
143 proto static string Report();
145 proto native static int GetNSuites();
147 proto native static TestSuite GetSuite(int handle);
149 proto native static TestSuite ActiveSuite();
151 proto native static bool Finished();
153 proto native static void Begin();
155 proto native static void End();
156}
157
158//-----------------------------------------------------------------------------
160class TestSuite : Managed
161{
164 proto native void SetResult(TestResultBase res);
166 proto native int GetNTests();
168 proto native TestBase GetTest(int handle);
170 proto native void SetEnabled(bool val);
172 proto native bool IsEnabled();
174 proto string GetName();
176 protected void OnInit();
177}
178
179//-----------------------------------------------------------------------------
182{
185 proto native void SetResult(TestResultBase res);
187 proto native TestResultBase GetResult();
189 proto native void SetEnabled(bool val);
191 proto native bool IsEnabled();
193 proto string GetName();
194}
195
196//-----------------------------------------------------------------------------
201class TestResultBase : Managed
202{
204 bool Failure() { return NativeFailure(); }
205
206 string FailureText() { return NativeFailureText(); }
207
208 // Script forwarding to cpp. Otherwise the script overloading wouldn't be able
209 // to call the native base implementation.
210 // ----------------- vvv -----------------
211 proto native bool NativeFailure();
212 proto native string NativeFailureText();
213 // ----------------- ^^^ -----------------
214}
215
219
220//-----------------------------------------------------------------------------
221// EXAMPLES
222//-----------------------------------------------------------------------------
223/*
224//-----------------------------------------------------------------------------
226class TestBoolResult : TestResultBase
227{
228 bool Value;
229
230 void TestBoolResult(bool val) { Value = val; }
231
232 override bool Failure() { return !Value; }
233
234 override string FailureText()
235 {
236 // junit kind of error report. (simple)
237 return "<failure type=\"BoolResult\">Failed</failure>";
238 }
239}
240
241//-----------------------------------------------------------------------------
242class MyHarness : TestHarness
243{
244}
245
246//-----------------------------------------------------------------------------
247class MyTestSuite : TestSuite
248{
249 int cnt;
250
251 [Step(EStage.Setup)]
252 void Prep()
253 {
254 Print("MyTestSuite::Prep");
255 cnt = 3;
256 }
257
258 [Step(EStage.Setup)]
259 bool Count()
260 {
261 --cnt;
262 Print("MyTestSuite::Count: cnt=" + cnt);
263 return cnt == 0;
264 }
265
266 [Step(EStage.TearDown)]
267 bool CountUp()
268 {
269 ++cnt;
270 Print("MyTestSuite::CountUp: cnt=" + cnt);
271 return cnt == 10;
272 }
273}
274
275//-----------------------------------------------------------------------------
276[Test("MyTestSuite")]
277TestResultBase MyTest()
278{
279 Print("MyFuncTest");
280 return new TestBoolResult(true);
281}
282
283//-----------------------------------------------------------------------------
284[Test("MyTestSuite")]
285class MyAsyncTest : TestBase
286{
287 int counter;
288
289 [Step(EStage.Main)]
290 void Set()
291 {
292 counter = 10;
293 }
294
295 [Step(EStage.Main)]
296 bool Pool()
297 {
298 Print("AsyncTest::Pool::counter=" + counter);
299
300 if(counter == 0)
301 {
302 Print("AsyncTest::Pool::Result");
303 SetResult(new TestBoolResult(false));
304 return true;
305 }
306
307 Print("AsyncTest::Pool::Progress");
308
309 counter--;
310 return false;
311 }
312}
313*/
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
Определения TrapTrigger.c:119
TODO doc.
Определения EnScript.c:118
int SortOrder
Определения TestingFramework.c:102
void Test(string suite, int timeoutS=0, int timeoutMs=0, int sortOrder=0)
Defines a suite the test belongs to, its timeout value and order within the suite.
Определения TestingFramework.c:105
int TimeoutMs
Определения TestingFramework.c:101
string Suite
Определения TestingFramework.c:98
int TimeoutS
Определения TestingFramework.c:100
proto native void SetResult(TestResultBase res)
proto native bool IsEnabled()
Enabled flag getter.
proto native TestResultBase GetResult()
Result getter.
proto native void SetEnabled(bool val)
Enables/Disables the test. Disabled tests won't run at all.
proto string GetName()
Test name getter. Strictly for UI porposes!
Test base class.
Определения TestingFramework.c:182
proto static native bool Finished()
Returns true when all tests and suites finished.
proto static native TestSuite GetSuite(int handle)
Returns a test suite.
proto static native void End()
Finalizes the testing process.
proto static native int GetNSuites()
Returns number of test suites.
static proto string Report()
Generates a xml report.
proto static native bool Run()
proto static native TestSuite ActiveSuite()
Returns currently active TestSuite or null when none is active.
proto static native void Begin()
Starts up the testing process and initializes the structures.
Collection and main interface of the Testing framework.
Определения TestingFramework.c:138
proto native bool IsEnabled()
Enabled flag getter.
void OnInit()
Callback for user defined initialization. Called for all suites during TestHarness....
Определения FreezeState.c:81
class Test Stage
Attribute which marks a method as part of the testing process.
proto native int GetNTests()
Returns the number for tests within this suite.
TestHarness Managed SetResult(TestResultBase res)
Collection of tests.
string FailureText()
Text used for xml report output.
Определения TestingFramework.c:206
void Step(EStage stage=EStage.Main)
Определения TestingFramework.c:129
class Test Setup
Stage definition used in conjunction with Step attribute.
class Test Main
proto native TestBase GetTest(int handle)
Returns a test.
proto native string NativeFailureText()
TestBase Managed Failure()
Return true of the result means failure.
Определения TestingFramework.c:204
proto native bool NativeFailure()
proto native owned string GetName()
Test name getter. Strictly for UI porposes!
Определения SyncedValue.c:119