How can I pass a variable from one feature file to other

倖福魔咒の 提交于 2019-12-11 05:15:02

问题


I have a variable in one of the scenario of a feature file which I need to use in the request body of second feature file.

For Example:

A.feature

Scenario: Test
Given url 'abc'
* def number = 12345
And request {tyu:'#(number)',dhd:'lkj'}
When method put
Then status 200

B.feature

Scenario: Test2
Given url 'pqr'
And request {tyu:'#(number)'}
When method put
Then status 200

Note: Number variable in A.feature is a 6 digit number which is randomly generated everytime and the same should be passed in B.feature file.


回答1:


Normally if you have two Scenario-s that depend on one another you have to combine them into one. Refer the docs here: https://github.com/intuit/karate#script-structure

But if you are really looking for how to initialize something and re-use it across all feature files, maybe you are looking for karate.callSingle(): https://github.com/intuit/karate#hooks

var result = karate.callSingle('get-token.feature');


来源:https://stackoverflow.com/questions/53517432/how-can-i-pass-a-variable-from-one-feature-file-to-other

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!