Karate 使用另一个变量从不同的功能文件调用场景
我有一个使用变量的场景的功能文件,例如:1。 我从另一个功能文件调用这个场景,但这次我想传递另一个变量,例如:2 要素文件A:generateDocument.FeatureKarate 使用另一个变量从不同的功能文件调用场景,karate,Karate,我有一个使用变量的场景的功能文件,例如:1。 我从另一个功能文件调用这个场景,但这次我想传递另一个变量,例如:2 要素文件A:generateDocument.Feature @generatedoc Scenario: Verify able to generate document for user Given path somepath And header Content-Type = 'application/json' And request {"userId
@generatedoc
Scenario: Verify able to generate document for user
Given path somepath
And header Content-Type = 'application/json'
And request {"userId": "abc123"}
When method POST
Then status 200
* table documentId
| id | docTitle |
| '#notnull' | "ijk" |
| '#notnull' | "xyz" |
And match response[*].id == $documentId[*].id
And match response[*].title == $documentId[*].docTitle
call read('generateDocument.feature@generatedoc') { userId: 'abc456'}
功能文件B:useDocument.Feature
@generatedoc
Scenario: Verify able to generate document for user
Given path somepath
And header Content-Type = 'application/json'
And request {"userId": "abc123"}
When method POST
Then status 200
* table documentId
| id | docTitle |
| '#notnull' | "ijk" |
| '#notnull' | "xyz" |
And match response[*].id == $documentId[*].id
And match response[*].title == $documentId[*].docTitle
call read('generateDocument.feature@generatedoc') { userId: 'abc456'}
因此,当我运行功能文件A时,它应该使用变量“abc123”,但当我运行功能文件B时,它应该使用变量“abc456”
但目前当我运行功能文件B时,它仍然使用'abc123'请在A中执行此操作-因此它成为一个可重用的功能
And request {"userId": "#(userId)"}
现在,您需要调用它两次(可能使用两种不同的功能,它将起作用):
特征B:
call read('generateDocument.feature') { userId: 'abc456' }
特征C:
call read('generateDocument.feature') { userId: 'abc123' }