Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AutotestReport.c
Go to the documentation of this file.
1
2
class
SCR_AutotestReport
3
{
4
protected
static
const
string
JUNIT_PATH
=
"$logs:/junit.xml"
;
5
protected
static
const
string
FAILED_LIST_PATH
=
"$logs:/autotest_failed.log"
;
6
7
protected
string
m_sJUnitXml
;
8
protected
ref set<TestBase>
m_aFailedTests
=
new
set<TestBase>();
9
protected
bool
m_bIsFailure
;
10
11
#ifdef WORKBENCH
12
protected
string
m_sDialogText;
13
#endif
14
15
void
CollectResults
()
16
{
17
SetJUnit
(
TestHarness
.Report(omitSkipped:
true
));
18
FillFailed
();
19
#ifdef WORKBENCH
20
FillDialog();
21
#endif
22
}
23
24
void
WriteJUnitXML
()
25
{
26
string
path
=
JUNIT_PATH
;
27
FileHandle
file =
FileIO
.OpenFile(
path
,
FileMode
.WRITE);
28
file.Write(
m_sJUnitXml
);
29
file.Close();
30
31
PrintFormat
(
"Autotest JUnit XML saved to: %1"
,
path
, level:
LogLevel
.NORMAL);
32
}
33
34
void
WriteFailedList
()
35
{
36
string
path
=
FAILED_LIST_PATH
;
37
FileHandle
file =
FileIO
.OpenFile(
path
,
FileMode
.WRITE);
38
foreach
(
TestBase
test :
m_aFailedTests
)
39
{
40
file.WriteLine(test.GetName());
41
}
42
43
file.Close();
44
45
PrintFormat
(
"Autotest failed list saved to: %1"
,
path
, level:
LogLevel
.NORMAL);
46
}
47
48
protected
void
SetJUnit
(
string
xml)
49
{
50
m_sJUnitXml
= xml;
51
}
52
53
protected
void
SetFailed
()
54
{
55
m_bIsFailure
=
true
;
56
}
57
58
//------------------------------------------------------------------------------------------------
59
protected
void
FillFailed
()
60
{
61
int
suitesCount =
TestHarness
.GetNSuites();
62
for
(
int
i; i < suitesCount; i++)
63
{
64
TestSuite
suite =
TestHarness
.GetSuite(i);
65
if
(!suite.IsEnabled())
66
continue
;
67
68
int
testsCount = suite.GetNTests();
69
for
(
int
j; j < testsCount; j++)
70
{
71
TestBase
test = suite.GetTest(j);
72
if
(!test.IsEnabled())
73
continue
;
74
75
TestResultBase
result = test.GetResult();
76
if
(!result || result.Failure())
77
{
78
SetFailed
();
79
m_aFailedTests
.Insert(test);
80
}
81
}
82
}
83
}
84
85
#ifdef WORKBENCH
86
//------------------------------------------------------------------------------------------------
87
protected
void
FillDialog()
88
{
89
int
failed, total;
90
91
int
suitesCount =
TestHarness
.GetNSuites();
92
for
(
int
i; i < suitesCount; i++)
93
{
94
TestSuite
suite =
TestHarness
.GetSuite(i);
95
if
(!suite.IsEnabled())
96
continue
;
97
98
m_sDialogText +=
string
.Format(
"%1:\n"
, suite.ClassName());
99
100
int
testsCount = suite.GetNTests();
101
for
(
int
j; j < testsCount; j++)
102
{
103
TestBase
test = suite.GetTest(j);
104
if
(!test.IsEnabled())
105
continue
;
106
107
m_sDialogText +=
string
.Format(
"\t%1\n"
, GetTestResultLine(test, failed));
108
total++;
109
}
110
111
m_sDialogText +=
"\n"
;
112
}
113
114
m_sDialogText +=
string
.Format(
"FAILED: %1\nTOTAL: %2"
, failed, total);
115
}
116
117
//------------------------------------------------------------------------------------------------
118
void
OpenDialog()
119
{
120
string
title =
"Test result"
;
121
if
(
m_bIsFailure
)
122
{
123
title +=
" FAILURE"
;
124
}
125
else
126
{
127
title +=
" SUCCESS"
;
128
}
129
130
Workbench.ScriptDialog(title, m_sDialogText,
this
);
131
}
132
133
//------------------------------------------------------------------------------------------------
134
[
ButtonAttribute
(label:
"Open autotest.log"
)]
135
void
ButtonOpenLog()
136
{
137
ScriptEditor se = Workbench.GetModule(ScriptEditor);
138
se.SetOpenedResource(SCR_AutotestPrinter.LOG_PATH);
139
}
140
141
//------------------------------------------------------------------------------------------------
142
private
string
GetTestResultLine(TestBase test, out
int
failedCount)
143
{
144
TestResultBase result = test.GetResult();
145
if
(!result)
146
{
147
SetFailed
();
148
failedCount++;
149
return
string
.Format(
"⚠️ %1: NO_RESULT"
, test.GetName());
150
}
151
152
if
(TestResultTimeout.Cast(result))
153
{
154
SetFailed
();
155
failedCount++;
156
return
string
.Format(
"⌚ %1: FAILURE"
, test.GetName());
157
}
158
159
if
(result.Failure())
160
{
161
SetFailed
();
162
failedCount++;
163
return
string
.Format(
"⛔ %1: FAILURE"
, test.GetName());
164
}
165
166
return
string
.Format(
"✅ %1: SUCCESS"
, test.GetName());
167
}
168
#endif
169
170
}
path
string path
Definition
AddonBuildInfoTool.c:249
ButtonAttribute
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
Definition
WorkbenchDialogs.c:30
FileHandle
Definition
FileHandle.c:69
FileIO
Definition
FileIO.c:13
SCR_AutotestReport
Definition
SCR_AutotestReport.c:3
SCR_AutotestReport::WriteFailedList
void WriteFailedList()
Definition
SCR_AutotestReport.c:34
SCR_AutotestReport::SetJUnit
void SetJUnit(string xml)
Definition
SCR_AutotestReport.c:48
SCR_AutotestReport::m_aFailedTests
ref set< TestBase > m_aFailedTests
Definition
SCR_AutotestReport.c:8
SCR_AutotestReport::CollectResults
void CollectResults()
Definition
SCR_AutotestReport.c:15
SCR_AutotestReport::JUNIT_PATH
static const string JUNIT_PATH
Definition
SCR_AutotestReport.c:4
SCR_AutotestReport::FAILED_LIST_PATH
static const string FAILED_LIST_PATH
Definition
SCR_AutotestReport.c:5
SCR_AutotestReport::m_sJUnitXml
string m_sJUnitXml
Definition
SCR_AutotestReport.c:7
SCR_AutotestReport::SetFailed
void SetFailed()
Definition
SCR_AutotestReport.c:53
SCR_AutotestReport::FillFailed
void FillFailed()
Definition
SCR_AutotestReport.c:59
SCR_AutotestReport::m_bIsFailure
bool m_bIsFailure
Definition
SCR_AutotestReport.c:9
SCR_AutotestReport::WriteJUnitXML
void WriteJUnitXML()
Definition
SCR_AutotestReport.c:24
TestBase
Test base class.
Definition
TestBase.c:14
TestHarness
Collection of suites and main interface of the Testing framework.
Definition
TestHarness.c:14
TestResultBase
Definition
TestResultBase.c:17
TestSuite
Collection of tests. Provides API for environment preparation.
Definition
TestSuite.c:14
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)
FileMode
FileMode
Mode for opening file. See FileSystem::Open.
Definition
FileMode.c:14
scripts
Autotest
Game
TestFramework
SCR_AutotestReport.c
Generated by
1.17.0