网站建设越来越注重用户体验,千锋教育培训机构学费,广告制作合同范本,帝国网站管理系统安装#x1f345; 我是蚂蚁小兵#xff0c;专注于车载诊断领域#xff0c;尤其擅长于对CANoe工具的使用#x1f345; 寻找组织 #xff0c;答疑解惑#xff0c;摸鱼聊天#xff0c;博客源码#xff0c;点击加入#x1f449;【相亲相爱一家人】#x1f345; 玩转CANoe 我是蚂蚁小兵专注于车载诊断领域尤其擅长于对CANoe工具的使用 寻找组织 答疑解惑摸鱼聊天博客源码点击加入【相亲相爱一家人】 玩转CANoe博客目录大全点击跳转 前言 在做测试用例开发的时候我们可能期望在执行测试用例之前做一些变量初始化复制文本处理等前瞻性工作 有些小伙伴可能想通过on start 和 on prestart 实现但这是不理智的在test units and test modules中on start 是不可用的而 on prestart 初始化变量等是不可靠的。 所以如果是XML test modules类型的测试用例想要完成初始化的一些工作使用XML调用 CAPL Test Function是一个不错的选择 CANoe中XML编程常用语法前言CAPL Test Function测试用例1preparation标签下的无参数调用测试用例2testcase标签下的带参数调用测试用例3completion标签下的带参数调用总结CAPL Test Function
下图是Call CAPL Test Function的Help解释
1XML test module 中的XML文件可以调用CAPL中的Test Function且只能被XML调用。2调用capl中的testfunction用capltestfunction标签且该标签无法独立使用需被 或 或 标签包含使用。 3以最简单的例子 capltestfunction nametest_01 titlecall test function : test_01/capltestfunctionname的值必须和CAPL中的testfunction 一致。title 的值可以任意填写 4testfunction 的函数是没有返回值的。 5capltestfunction是可以传参调用的支持的参数有float|int|string|signal|envvar|sysvar 测试用例1preparation标签下的无参数调用
1️⃣ 如下图的CAPL界面创建了一个testfunction test_01() 2️⃣ 创建的xml文件如下图通过 capltestfunction 标签调用 capl脚本中创建的 test_01函数 testmodule titleXML Test Module version1.1descriptionXML Test Module/descriptionpreparationinitialize titleInitialize test module wait200!-- envvar name1/envvar --/initializecapltestfunction nametest_01 titlecall test function : test_01/capltestfunction/preparationtestgroup titleUDS capltestcase nameTC_0001 //testgroupcompletioninitialize titleAdding testreport info wait500!-- envvar name0/envvar --/initialize/completion
/testmodule 2️⃣ 例如新建一个xml文件命名为test.xml ,写入如下代码新建一个XML Test Modele 节点测试下观察测试报告的输出
?xml version1.0 encodingiso-8859-1 standaloneyes?
testmodule titletestmodel_tag version1.13/testmodule 3️⃣ 根据输出报告可以看出 title“testmodel_tag” 输出的报告名字就是testmodel_tag 3️⃣ 创建的Test Module测试节点。然后执行测试根据结果可以看到XML成功调用了函数test_01 测试用例2testcase标签下的带参数调用
1️⃣ 如下图的CAPL界面创建了一个testfunction test_02(int s) 2️⃣通过 testcase 标签调用 capl脚本中创建的 test_02函数
testmodule titleXML Test Module version1.1descriptionXML Test Module/descriptionpreparationinitialize titleInitialize test module wait200!-- envvar name1/envvar --/initializecapltestfunction nametest_01 titlepreparation标签下的无参数调用/capltestfunction/preparationtestgroup titleUDS capltestcase nameTC_0001 /testcase titleTC_0002 identTC_0002 capltestfunction nametest_02 titletestcase标签下的带参数调用caplparam namepara1 typeint0x01/caplparam/capltestfunction/testcase/testgroupcompletioninitialize titleAdding testreport info wait500!-- envvar name0/envvar --/initialize/completion
/testmodule3️⃣ 输出结果根据结果可以看到XML成功调用了函数test_02 测试用例3completion标签下的带参数调用
1️⃣ 如下图的CAPL界面创建了一个testfunction test_03(char s[])
/*!Encoding:936*/
testfunction test_01()
{write(***************XML调用了 testfunction test_01***************);
}testfunction test_02(int s)
{write(***************XML调用了 testfunction test_02 接收参数%d***************,s);
}testfunction test_03(char s[])
{write(***************XML调用了 testfunction test_03 接收参数%s***************,s);
}testcase TC_0001()
{} 2️⃣通过 completion 标签调用 capl脚本中创建的 test_03函数
testmodule titleXML Test Module version1.1descriptionXML Test Module/descriptionpreparationcapltestfunction nametest_01 titlepreparation标签下的无参数调用/capltestfunction/preparationtestgroup titleUDS capltestcase nameTC_0001 /testcase titleTC_0002 identTC_0002 capltestfunction nametest_02 titletestcase标签下的带参数调用caplparam namepara1 typeint0x01/caplparam/capltestfunction/testcase/testgroupcompletioncapltestfunction nametest_03 titlecompletion标签下的带参数调用caplparam namepara1 typestringhello/caplparam/capltestfunction/completion
/testmodule 3️⃣ 输出结果根据结果可以看到XML成功调用了函数test_03
总结 要有最朴素的生活最遥远的梦想即使明天天寒地冻路遥马亡 如果这篇博客对你有帮助请 “点赞” “评论”“收藏”一键三连 哦码字不易大家的支持就是我坚持下去的动力。