在调用另一个特征文件时传递 JSON 数组
Passing a JSON array while calling another feature file
根据 https://github.com/intuit/karate#data-driven-features,当我们将 JSON 数组作为参数传递给另一个功能文件的调用时,会为数组中的每个项目调用该功能。
有没有办法避免这种情况?我想将完整的 JSON 数组视为我对另一个功能文件的请求
示例:
[
{
"attr1" :"123",
"attr2" :"456"
},
{
"attr1" :"789",
"attr2" :"101112"
}
]
我目前正在将此有效负载传递给另一个功能文件:
* call read('classpath:com/example/Test.feature') myReq
现在我的 Test.feature 被执行了两次,对 JSON 数组中的每个项目执行一次。但是我的完整 JSON 数组将作为请求传递给 Test.feature。我们怎样才能做到这一点?
包装它:
* def array = []
* def arg = { data: '#(array)' }
* call read('classpath:com/example/Test.feature') arg
根据 https://github.com/intuit/karate#data-driven-features,当我们将 JSON 数组作为参数传递给另一个功能文件的调用时,会为数组中的每个项目调用该功能。
有没有办法避免这种情况?我想将完整的 JSON 数组视为我对另一个功能文件的请求 示例:
[
{
"attr1" :"123",
"attr2" :"456"
},
{
"attr1" :"789",
"attr2" :"101112"
}
]
我目前正在将此有效负载传递给另一个功能文件:
* call read('classpath:com/example/Test.feature') myReq
现在我的 Test.feature 被执行了两次,对 JSON 数组中的每个项目执行一次。但是我的完整 JSON 数组将作为请求传递给 Test.feature。我们怎样才能做到这一点?
包装它:
* def array = []
* def arg = { data: '#(array)' }
* call read('classpath:com/example/Test.feature') arg