Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AutotestCaseBase.c
Go to the documentation of this file.
1
6{
7 //------------------------------------------------------------------------------------------------
11 TestResultBase AssertTrue(bool expression, string msg)
12 {
13 TestResultBase result = GetResult();
14 if (result && result.Failure())
15 return result;
16
17 if (!expression)
18 {
19 result = SCR_AutotestResult.AsFailure("AssertTrue: %1", msg);
20 SetResult(result);
21 }
22
23 return result;
24 }
25
26 //------------------------------------------------------------------------------------------------
31 notnull TestResultBase SetResultSuccess(bool force = false)
32 {
33 TestResultBase result = GetResult();
34 if (!force && result && result.Failure())
35 return result;
36
38 SetResult(result);
39
40 return result;
41 }
42
43 //------------------------------------------------------------------------------------------------
50 notnull TestResultBase SetResultFailure(string reason, string param1 = "", string param2 = "", string param3 = "")
51 {
52 TestResultBase result = GetResult();
53 if (result && result.Failure())
54 return result;
55
57 SetResult(result);
58
59 return result;
60 }
61
62 //------------------------------------------------------------------------------------------------
64 TestSuite GetSuite()
65 {
66 for (int i, countSuites = TestHarness.GetNSuites(); i < countSuites; i++)
67 {
68 TestSuite suite = TestHarness.GetSuite(i);
69 for (int j, countTests = suite.GetNTests(); j < countTests; j++)
70 {
71 TestBase test = suite.GetTest(j);
72 if (test.Type() == this.Type())
73 return suite;
74 }
75 }
76
77 return null;
78 }
79
80 //------------------------------------------------------------------------------------------------
83 void Print(string msg, LogLevel level = LogLevel.NORMAL)
84 {
85 SCR_AutotestHarness.GetLogger().Log("\t"+msg, level);
86 }
87
88 //------------------------------------------------------------------------------------------------
91 void PrintFormat(string fmt, string param1 = "", string param2 = "", string param3 = "", LogLevel level = LogLevel.NORMAL)
92 {
93 SCR_AutotestHarness.GetLogger().Log(string.Format("\t"+fmt, param1, param2, param3), level);
94 }
95
96 //------------------------------------------------------------------------------------------------
99 void PrintOnce(string msg, LogLevel level = LogLevel.NORMAL)
100 {
101 SCR_AutotestHarness.GetLogger().LogOnce("\t"+msg, level);
102 }
103
104 //------------------------------------------------------------------------------------------------
105 [Step(EStage.Setup)]
106 private void Setup_Logger()
107 {
108 SCR_AutotestHarness._SetActiveTestCase(this);
109 }
110
111 //------------------------------------------------------------------------------------------------
112 [Step(EStage.TearDown)]
113 private void TearDown_PrintTestResult()
114 {
115 SCR_AutotestHarness.GetLogger().LogTestCaseResult(this);
116 }
117
118 //------------------------------------------------------------------------------------------------
119 [Step(EStage.TearDown)]
120 private void TearDown_Logger()
121 {
122 SCR_AutotestHarness._SetActiveTestCase(null);
123 }
124}
void LogOnce(string msg, LogLevel level=LogLevel.NORMAL)
Prevents duplicate printing of the same message. Intended to be used with messages printed many times...
void Log(string msg, LogLevel level=LogLevel.NORMAL, bool forceFileWrite=false, bool consoleLog=true)
Should be used in tests instead of global Print. Forwards test output to separate file.
void LogTestCaseResult(TestBase test)
static SCR_AutotestResult AsFailure(string reason, string param1="", string param2="", string param3="")
static SCR_AutotestResult AsSuccess()
Test base class.
Definition TestBase.c:14
Collection of suites and main interface of the Testing framework.
Definition TestHarness.c:14
Collection of tests. Provides API for environment preparation.
Definition TestSuite.c:14
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
class TestStep Step
class Test EStage
T3 param3
Definition tuple.c:93
T2 param2
Definition tuple.c:92
Tuple param1