在功能文件的一种情况下,我有一个变量,我需要在第二个功能文件的请求正文中使用它。
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
注意:A.feature中的数字变量是一个6位数字,每次都会随机生成,因此应在B.feature文件中传递相同的数字。
答案 0 :(得分:1)
通常,如果您有两个相互依赖的Scenario
-,则必须将它们组合为一个。在此处参考文档:https://github.com/intuit/karate#script-structure
但是,如果您真的在寻找如何初始化某些东西并在所有所有功能文件中重复使用它们,也许您正在寻找karate.callSingle()
:https://github.com/intuit/karate#hooks
var result = karate.callSingle('get-token.feature');