ev123建站,手机网站制作平台免费,各大网站免费观看,江苏国龙翔建设公司网站前言
有小伙伴提到#xff0c;test_a.yml 中已经写了几个流程#xff0c;test_b.yml 中希望能接着test_a.yml去写用例#xff0c;于是就需要先导入test_a.yml用例。 为了满足此需求#xff0c;v1.6.3版本 在config 中新增 depend 关键字。
需求场景
test_a.yml 中已经写…前言
有小伙伴提到test_a.yml 中已经写了几个流程test_b.yml 中希望能接着test_a.yml去写用例于是就需要先导入test_a.yml用例。 为了满足此需求v1.6.3版本 在config 中新增 depend 关键字。
需求场景
test_a.yml 中已经写了一些用例
config:variables:x: helloy: worldtest_x1:name: xxrequest:method: posturl: http://httpbin.org/postjson:title: aamessage: bbbtest_x2:name: xxprint: ${x} -- ${y}test_b.yml 中可以在config 中添加depend 关键字, test_a.yml和test_a.yml 在同一个目录
config:depend: test_a.ymltest_b3:name: xxprint: 输出结果--${y}那么test_b.yml 就等价于把test_a.yml内容复制过来了
config:variables:x: helloy: worldtest_x1:name: xxrequest:method: posturl: http://httpbin.org/postjson:title: aamessage: bbbtest_x2:name: xxprint: ${x} -- ${y}test_b3:name: xxprint: 输出结果--${y}
所以会重复执行一次test_a.yml用例再执行test_b.yml 中的用例。
depend 关键字使用
depend 关键字使用规则
1.只能在 config 中使用因为它是接着前面一个 yml 用例继续写其他用例。2.目前只支持一个层级的引用如b 引入a, 不支持多层级引入如c引入b, b又引入了a3.depend 后面写用例文件的路径如果在同一目录可以直接写文件名称不在同一个目录需从项目根目录开始写相对路径。
当 test_a.yml 用例中有在config 定义变量 variables
config:variables:x: helloy: worldtest_x1:name: xxrequest:method: posturl: http://httpbin.org/postjson:title: aamessage: bbbtest_x2:name: xxprint: ${x} -- ${y}test_b.yml 中没有定义config变量时会默认读取test_a.yml 用例中定义的变量。
config:depend: test_a.ymltest_b3:name: xxprint: 输出结果--${y}test_b.yml 中也可以定义config 变量替换test_a.yml中的变量
config:depend: test_a.ymlvariables:y: aabcctest_b3:name: xxprint: 输出结果--${y}此时 test_b3 用例引用变量${y} 得到的结果就是 aabbcc
当用例中有局部变量时用例中定义的变量优先级是最高的
config:depend: test_a.ymlvariables:y: aabcctest_b3:name: xxvariables:y: aa1122print: 输出结果--${y}此时 test_b3 用例引用变量${y} 得到的结果就是 aa1122