5import isystem.connect
as ic
8def configure_test_reports(test_bench: ic.CTestBench):
9 report_config = test_bench.getTestReportConfig(
False)
10 report_config.setReportContents(ic.CTestReportConfig.RCONFIG_FULL)
11 report_config.setOutputFormat(ic.CTestReportConfig.FMT_XML)
12 report_config.setFileName(
'myTestReport.xml')
13 report_config.setIncludeTestSpec(
False)
16def create_test_case(velocity, accel, ret_val_value, function_name):
17 test_spec = ic.CTestSpecification()
19 test_func = test_spec.getFunctionUnderTest(
False)
20 test_func.setName(function_name)
22 params = ic.StrVector()
23 params.append(str(velocity))
24 params.append(str(accel))
25 test_func.setPositionParameters(params)
27 test_func.setRetValueName(
'retVal')
29 results = ic.StrVector()
30 results.append(f
'retVal == {ret_val_value}')
31 test_spec.setExpectedResults(results)
39 test_bench = ic.CTestBench()
41 configure_test_reports(test_bench)
44 test_case1 = create_test_case(velocity=10, accel=20, ret_val_value=30,
45 function_name=
'calculate')
46 test_case2 = create_test_case(velocity=-10, accel=-20, ret_val_value=-30,
47 function_name=
'calculate')
50 root_test_case = test_bench.getTestSpecification(
False)
51 root_test_case.addChildAndSetParent(-1, test_case1)
52 root_test_case.addChildAndSetParent(-1, test_case2)
55 test_bench.save(
'myTests.iyaml',
False,
False)
58if __name__ ==
'__main__':