* def runOperation1 = read('classpath:ic/common/resources/operation/runOperation.feature')
* def operationInputData = read('classpath:ic/feature/streaming/TestData/operationData.json')
* def result = call runOperation1 operationInputData
* def AllResponse = $result[*].response
* print AllResponse
在完成json数组的所有执行后,将在此处填充“ AllResponse”。 对于每个json数组,我们需要调用其他功能并声明一些值。然后我们需要遍历json数组中的另一个元素
答案 0 :(得分:2)
我看到了两种解决方法,
1,在您的runOperation.feature
2,而不是call
为runOperation.feature
中的场景创建动态场景大纲,并在该场景中添加您的呼叫步骤
编辑:
假设operationData.json
为
[
{"name": "Johan"},
{"name": "Ben"}
]
将runOperation.feature
假定为
Feature: run operation feature
Scenario: run operation Scenario
Given url "http://httpbin.org/get"
And path name
And method get
And status 200
将anothercall.feature
假定为
Feature: another call feature
Scenario: another call scenario
Given url "http://httpbin.org/get"
And path name
And method delete
And status 200
现在您可以使用当前功能了,
Background:
* def operationInputData = read('classpath:ic/feature/streaming/TestData/operationData.json')
Scenario Outline:
# steps from runoperation.feature
Given url "http://httpbin.org/get"
And path <name>
And method get
And status 200
# calling another feature
Then def anotherCall = call read("anothercall.feature") {"name": <name>}
# match / assert condition
Examples:
|operationInputData|
我建议选择第二个选项,因为第一个选项可能导致不必要的并发症。