39 Print(
"(SCR_AutotestHarness) Tests to run:", level:
LogLevel.DEBUG);
41 for (
int i = 0; i < suitesCount; i++)
46 int testsCount = suite.GetNTests();
47 for (
int j = 0; j < testsCount; j++)
60 Print(
"SCR_AutotestHarness::Begin was called while the test is already running",
LogLevel.ERROR);
63 testGroup = GetDefaultTestGroupConfig();
65 ConfigureTestGroup(testGroup);
66 BeginInternal(autorun, verboseLog);
74 Print(
"SCR_AutotestHarness::Begin was called while the test is already running",
LogLevel.ERROR);
76 array<ref SCR_AutotestSuiteBase> wantedSuites = {testSuite};
77 ConfigureTestSuites(wantedSuites);
79 BeginInternal(autorun, verboseLog);
87 Print(
"SCR_AutotestHarness::Begin was called while the test is already running",
LogLevel.ERROR);
89 ConfigureTestCases({testCase});
91 BeginInternal(autorun, verboseLog);
96 private static void BeginInternal(
bool autorun,
bool verboseLog)
110 WorldEditor we = Workbench.GetModule(WorldEditor);
117 we.SwitchToGameMode();
124 static SCR_AutotestReport Finish(
bool abort =
false)
127 s_Logger.Log(
"Test run was aborted by going back to editor mode...", forceFileWrite:
true);
134 _SetActiveTestCase(null);
144 if (SCR_AutotestHarness.s_bOpenLogAfterRun)
146 ScriptEditor scriptEditor = Workbench.GetModule(ScriptEditor);
147 scriptEditor.SetOpenedResource(SCR_AutotestPrinter.LOG_PATH);
148 SCR_AutotestHarness.s_bOpenLogAfterRun =
false;
151 if (SCR_AutotestHarness.s_bOpenDialogAfterRun)
154 SCR_AutotestHarness.s_bOpenDialogAfterRun =
false;
163 static void _SetActiveTestCase(TestBase testCase)
170 static TestBase ActiveTestCase()
177 private static void ConfigureTestGroup(notnull SCR_AutotestGroup testGroup)
179 ConfigureTestSuites(testGroup.GetSuites());
184 private static void ConfigureTestSuites(notnull array<ref SCR_AutotestSuiteBase> wantedSuites)
186 int allSuiteCount = GetNSuites();
187 for (
int i = 0; i < allSuiteCount; i++)
189 TestSuite suite = GetSuite(i);
190 suite.SetEnabled(
false);
191 foreach (SCR_AutotestSuiteBase wantedSuite : wantedSuites)
194 if (suite.ClassName() == wantedSuite.ClassName())
196 int suiteTestsCount = suite.GetNTests();
197 for (
int j = 0; j < suiteTestsCount; j++)
199 TestBase test = suite.GetTest(j);
200 test.SetEnabled(
true);
203 suite.SetEnabled(
true);
212 private static void ConfigureTestCases(notnull array<ref SCR_AutotestCaseBase> wantedTests)
214 int allSuiteCount = GetNSuites();
215 array<TestSuite> allTestSuites = {};
216 for (
int i = 0; i < allSuiteCount; i++)
218 TestSuite suite = GetSuite(i);
219 suite.SetEnabled(
false);
220 allTestSuites.Insert(suite);
229 foreach (SCR_AutotestCaseBase wantedTest : wantedTests)
231 foreach (TestSuite suite : allTestSuites)
233 int suiteTestsCount = suite.GetNTests();
234 bool testFoundInThisSuite =
false;
235 for (
int i = 0; i < suiteTestsCount; i++)
237 TestBase test = suite.GetTest(i);
239 test.SetEnabled(
false);
241 if (test.ClassName() == wantedTest.ClassName())
243 testFoundInThisSuite =
true;
244 test.SetEnabled(
true);
245 suite.SetEnabled(
true);
251 if (testFoundInThisSuite)
258 private static void OnTestEnabled(TestBase test)
261 SCR_AutotestDebugMenu.GetInstance().s_aAllTests.Insert(test.Type());
266 static SCR_AutotestPrinter GetLogger()
274 static SCR_AutotestGroup GetDefaultTestGroupConfig()
280 return new SCR_AutotestGroup();
static void Begin(SCR_AutotestGroup testGroup, bool autorun=false, bool verboseLog=false)
Configures the test runner to execute only the test suites present in the specified test group and in...
static void Begin(notnull SCR_AutotestCaseBase testCase, bool autorun=false, bool verboseLog=false)
Configures the test runner to execute single test case and initializes required structures.
static void Begin(notnull SCR_AutotestSuiteBase testSuite, bool autorun=false, bool verboseLog=false)
Configures the test runner to execute single test suite and initializes required structures.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
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)