5import isystem.connect
as ic
6import isystem.itest
as it
12def createExampleOfLogEntry():
13 lr = ic.CLogResult(
None)
14 lr.add(
'counter',
'234', ic.CLogResult.E_SECTION_BEFORE_ASSIGN)
15 lr.add(
'size',
'25', ic.CLogResult.E_SECTION_AFTER_ASSIGN)
20def createExampleOfStubResult(hitNo, stepIdx):
21 sr = ic.CTestPointResult(
None)
23 sr.setLogResult(createExampleOfLogEntry())
24 sr.setExecStatus(ic.CTestPointResult.EXECUTED)
25 sr.setHitNoAndStepIdx(hitNo, stepIdx)
26 sr.setScriptInfoVar(
"evaluated all expressions")
27 sr.setScriptRetVal(
"")
28 sr.addExpressionError(
"a == 10",
"a = 9")
33def createExampleOfTestPointResult():
34 sr = ic.CTestPointResult(
None)
35 sr.setId(
'myTestPointID')
36 sr.setLocation(
'src/main.cpp')
37 sr.setLogResult(createExampleOfLogEntry())
38 sr.setExecStatus(ic.CTestPointResult.EXECUTED)
39 sr.setHitNoAndStepIdx(0, 0)
40 sr.setScriptInfoVar(
"evaluated all expressions")
42 sr.setScriptRetVal(
"Eval. failed!")
47def createExampleOfStackUsage():
48 su = ic.CStackUsageResult(
None)
51 stackUsedBeforeTest = 150
55 su.setValues(minExpectedSize, maxExpectedSize, stackUsedBeforeTest,
61def createExampleOfPreConditionResult(isError):
62 pc = ic.CTestExprResult(
None)
63 pc.setExpression(
'a == 2')
64 pc.addSubexpression(
'a',
'2')
70def createExampleOfExprResult(expr, subExpr, value, isError):
71 pc = ic.CTestExprResult(
None)
72 pc.setExpression(expr)
73 pc.addSubexpression(subExpr, value)
79def createExampleOfTestResult():
80 testSpec = ic.CTestSpecification()
81 testSpec.setTestId(
'demoTest')
82 testResult = ic.CTestResult(testSpec)
83 testResult.setResultComment(
'This is demo script for test report creation')
84 testResult.setTargetException(
False)
85 testResult.appendScriptOutput(
"",
"timing OK")
87 testResult.addStubResult(createExampleOfStubResult(0, 0))
89 testResult.addStubResult(createExampleOfStubResult(1, 0))
90 testResult.addTestPointResult(createExampleOfTestPointResult())
91 testResult.setStackUsageResult(createExampleOfStackUsage())
92 testResult.addExprResult(ic.CTestResult.E_SECTION_PRE_CONDITION,
93 createExampleOfPreConditionResult(
False))
94 testResult.addExprResult(ic.CTestResult.E_SECTION_ASSERT,
95 createExampleOfExprResult(
'a == 4',
'a',
'2',
True))
96 testResult.setLogResult(createExampleOfLogEntry())
101def getWinIDEAVersion():
102 cm = ic.ConnectionMgr()
103 cm.connect(ic.CConnectionConfig().instanceId(winidea_id))
104 ide = ic.CIDEController(cm)
105 ver = ide.getWinIDEAVersion()
106 return ver.toString()
109def createExampleOfReportConfig():
111 reportConfig = ic.CTestReportConfig()
113 reportConfig.setReportContents(ic.CTestReportConfig.RCONFIG_FULL)
114 reportConfig.setTestIDEAVersion(
"0.9")
115 cm = ic.ConnectionMgr()
116 cm.connect(ic.CConnectionConfig().instanceId(winidea_id))
117 ide = ic.CIDEController(cm)
118 reportConfig.setWinIDEAVersion(getWinIDEAVersion())
119 reportConfig.setOutputFormat(ic.CTestReportConfig.FMT_XML)
120 reportConfig.setFileName(
'reportGeneratedByCustomScript.xml')
124 reportConfig.setIYamlFileName(
"./")
126 reportConfig.setXsltForFullReport(it.DEFAULT_XSLT)
127 reportConfig.setCssFile(it.BLUE_CSS)
129 reportConfig.setIncludeTestSpec(
False)
131 reportConfig.setXmlReportHeader(
"CUSTOM REPORT")
133 reportConfig.addUserInfo(
"date",
"2019-04-04")
134 reportConfig.addUserInfo(
"testerName",
"john")
139def saveTestReport(testResults, reportConfig):
140 resultContainer = ic.CTestReportContainer()
141 for testResult
in testResults:
142 resultContainer.putTestResult(ic.CTestSpecification(), testResult)
144 ic.CTestBench.saveTestResults(resultContainer, reportConfig)
147reportConfig = createExampleOfReportConfig()
149testResults.append(createExampleOfTestResult())
150saveTestReport(testResults, reportConfig)
155it.copyXsltAndCss(reportConfig)