如何为每次执行 json 数组循环调用其他功能

How to call some other feature for each execution of json array loop

    * 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

此处 'AllResponse' 在 json 数组的所有执行完成后填充。 对于每个 json 数组,我们需要调用一些其他功能并断言一些值。然后我们需要遍历json数组

中的另一个元素

我看到了 2 种方法,

1,将调用另一个功能和断言的额外步骤也添加到您的 runOperation.feature

2,而不是 callrunOperation.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|

我建议选择第二个选项,因为第一个选项可能会导致不必要的复杂化。