![](/img/trans.png)
[英]Karate API Testing - Passing variable from one feature file to another
[英]How can I call a variable from one feature file to another feature file using Karate API Testing
Feature: Add data
Scenario: Add unique data
Given url
And request {name: '#(name)', lastName: '#(lastName)'}
And method POST
Then status 200
And def res = response
And def newId = res.data.id
上面的api一被调用就会生成一个id。 我想使用另一个文件中生成的 id 来更新数据。 我已将 id 存储在 'newId' 变量中。 如何在另一个功能文件中使用此变量及其值?
这在文档中有详细解释 - 您应该实际阅读它:)
因此,如果您有一个called.feature
的功能,如下所示:
Feature:
Scenario:
* print newId
您可以将此添加为您发布的代码的最后一行:
* call read('called.feature') { newId: '#(newId)' }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.