1
2
3
4
5import isystem.connect as ic
6
7
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)
14
15
16def create_test_case(velocity, accel, ret_val_value, function_name):
17 test_spec = ic.CTestSpecification()
18
19 test_func = test_spec.getFunctionUnderTest(False)
20 test_func.setName(function_name)
21
22 params = ic.StrVector()
23 params.append(str(velocity))
24 params.append(str(accel))
25 test_func.setPositionParameters(params)
26
27 test_func.setRetValueName('retVal')
28
29 results = ic.StrVector()
30 results.append(f'retVal == {ret_val_value}')
31 test_spec.setExpectedResults(results)
32
33 return test_spec
34
35
36def main():
37
38
39 test_bench = ic.CTestBench()
40
41 configure_test_reports(test_bench)
42
43
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')
48
49
50 root_test_case = test_bench.getTestSpecification(False)
51 root_test_case.addChildAndSetParent(-1, test_case1)
52 root_test_case.addChildAndSetParent(-1, test_case2)
53
54
55 test_bench.save('myTests.iyaml', False, False)
56
57
58if __name__ == '__main__':
59 main()