Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TEST_Example1TestSuite.c
Go to the documentation of this file.
1#ifdef WORKBENCH
2
4sealed class SCR_Example1Subject
5{
6 // method with broken implementation
7 int GetFive()
8 {
9 return 4;
10 }
11}
12
13//[BaseContainerProps(category: "Autotest")]
14class SCR_TEST_Example1SubjectSuite : SCR_AutotestSuiteBase
15{
16 override ResourceName GetWorldFile()
17 {
18 return SCR_AutotestHelper.GetDefaultWorld();
19 }
20}
21
22[Test(suite: SCR_TEST_Example1SubjectSuite)]
23class SCR_TEST_Example1Subject_Counter_CountsToFive : SCR_AutotestCaseBase
24{
25 int m_iCounter;
26 // Class instance will not be deleted between test runs.
27 // Any class properties must be initialized in Setup stages.
28 // TODO should we change that behaviour? I feel like this is a bit unexpected.
29 int m_iExecutedTimes = 0;
30
31 [Step(EStage.Setup)]
32 void Setup()
33 {
34 m_iCounter = 0;
35 }
36
37 [Step(EStage.Main)]
38 bool Execute()
39 {
40 PrintFormat("Execute: %1, %2", GetName(), m_iCounter.ToString());
41 m_iCounter += 1;
42
43 if (m_iCounter <= 5)
44 {
45 return false; // keep running
46 }
47
48 SetResult(SCR_AutotestResult.AsSuccess());
49 return true; // finish the test
50 }
51
52 [Step(EStage.TearDown)]
53 void TearDown()
54 {
55 m_iExecutedTimes++;
56 PrintFormat("TearDown: %1, was executed %2 times since game start", GetName(), m_iExecutedTimes.ToString());
57 }
58}
59
60[Test(suite: SCR_TEST_Example1SubjectSuite)]
61class SCR_TEST_Example1Subject_GetFive_ReturnsFive : SCR_AutotestCaseBase
62{
63 [Step(EStage.Main)]
64 bool Execute()
65 {
66 SCR_Example1Subject subject = new SCR_Example1Subject();
67 int result = subject.GetFive();
68
69 Print("Lets see if GetFive() returns five...");
70
71 if (result == 5)
72 {
73 SetResult(SCR_AutotestResult.AsSuccess());
74 }
75 else
76 {
77 SetResult(SCR_AutotestResult.AsFailure("Expected 5, got %1", result.ToString()));
78 }
79
80 // AssertTrue can be used instead of above construct for more concise code.
81 // if the test is already failed the result will not be overwritten.
82 AssertTrue(result == 5, "Result is five");
83
84 return true;
85 }
86}
87
88[Test(suite: SCR_TEST_Example1SubjectSuite, timeoutMs: 10)]
89class SCR_TEST_Example1Subject_TimeoutExample : SCR_AutotestCaseBase
90{
91 [Step(EStage.Main)]
92 bool Execute()
93 {
94 PrintOnce("Waiting for timeout");
95 return false;
96 }
97}
98
99[Test(suite: SCR_TEST_Example1SubjectSuite)]
100class SCR_TEST_Example1Subject_NoResultExample : SCR_AutotestCaseBase
101{
102 [Step(EStage.Main)]
103 bool Execute()
104 {
105 return true;
106 }
107}
108
109#endif
bool Execute(notnull SCR_AIGroupUtilityComponent groupUtility, vector targetPosition, SCR_AIActivitySmokeCoverFeatureProperties smokeCoverProperties, notnull array< AIAgent > avoidAgents, notnull array< AIAgent > excludeAgents, int maxPositionCount=1, SCR_AIActivityBase contextActivity=null)
Attribute used for tests annotation and assignment to Suites.
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)
class TestStep Step
class Test EStage
@ Setup
Definition TestStage.c:15
@ TearDown
Definition TestStage.c:17