[英]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
One id will be generated as soon as above api is called.上面的api一被调用就会生成一个id。 I want to use the id generated in another file to update the data.
我想使用另一个文件中生成的 id 来更新数据。 I have stored the id in 'newId' variable.
我已将 id 存储在 'newId' 变量中。 How can I use this variable and its value in another feature file?
如何在另一个功能文件中使用此变量及其值?
This is explained in detail in the documentation - you should actually read it :)这在文档中有详细解释 - 您应该实际阅读它:)
So if you have a feature called.feature
as follows:因此,如果您有一个
called.feature
的功能,如下所示:
Feature:
Scenario:
* print newId
You can add this as the last line of the code you posted:您可以将此添加为您发布的代码的最后一行:
* call read('called.feature') { newId: '#(newId)' }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.