[英]Is there a way in Karate to call a Feature multiple time using karate.repeat or any other way?
我正在尝试测试一个需要发布100次请求的场景(这不是性能测试)。 我可以通过设置每100行来使用表功能,其中每行代表一个请求。 但是,这将是冗长乏味的。
因此,我找到了Karate.repeat,并希望这可以解决问题。 我只是想知道是否还有另一种方法可以实现我的目标。
* def users = function(i){ call read("classpath:v1/createCustomer.feature") { "firstName": '#(firstName)', "lastName": '#(lastName)' }
* def usersResult = karate.repeat(2, users )
* match usersResult [*].responseStatus == [204, 204]
我希望该功能被调用两次。
您应该能够对此使用repeat
,但是不要在DSL中使用call
而是使用karate.call
* def users = function(i){ return karate.call("classpath:v1/createCustomer.feature", { "firstName": '#(firstName)', "lastName": '#(lastName)' })
* def usersResult = karate.repeat(2, users )
* match each usersResult[*].responseStatus == 204
如果您希望每个呼叫使用不同的数据,还建议您检查空手道中的数据驱动和动态方案大纲选项。 正如您在问题中提到的,而不是使用100行数据表,您可以使用json数组或csv来实现相同目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.