我试图重用由API创建的orderId来测试对另一个API的调用。 我创建了1个订单,并想在方案大纲中重复使用该ID。 问题是后台执行了多次,因此下一次,orderId将被response.orderId覆盖。
我如何确保orderId仅设置一次,以后不会覆盖?
我的功能文件:
Feature: GET-order
Background:
* url demoUrl
Given path '/getOrder'
* def request = read('./request_template.json')
* callonce read('./create_order.feature')
* def orderId = response.orderId #this also should be done once
Scenario Outline: Test different values fromid
* print 'orderId: ' + orderId
* set request.orderId = orderId
* set request.fromId = <_fromId>
When method GET
Then status 200
Examples:
| _fromId |
| '1' |
| '2' |
答案 0 :(得分:0)
请从call
(或callonce
)访问how to return values上的文档:
尝试此更改:
Background:
* url demoUrl
* path '/getOrder'
* def payload = read('./request_template.json')
* def result = callonce read('./create_order.feature')
* def orderId = result.response.orderId