Karate 空手道加特林:报告中带有查询参数的请求未聚合
我正在空手道加特林做一个POC,以重复使用我的测试。我已经参考了文档并安装了这些版本。首先,像往常一样出色的工作,非常容易设置和启动 我正在从MySimualtion.scala调用一个功能文件,该文件还有以下三个抽象功能调用:Karate 空手道加特林:报告中带有查询参数的请求未聚合,karate,Karate,我正在空手道加特林做一个POC,以重复使用我的测试。我已经参考了文档并安装了这些版本。首先,像往常一样出色的工作,非常容易设置和启动 我正在从MySimualtion.scala调用一个功能文件,该文件还有以下三个抽象功能调用: * def tranRef = TransactionReferenceUtils.generateTransactionReferenceStartWith('09') * set payloadR /transaction_reference = tranRef
* def tranRef = TransactionReferenceUtils.generateTransactionReferenceStartWith('09')
* set payloadR /transaction_reference = tranRef
POST API >> /sending/v1/dm
* call read('classpath:../InitiateAbstract.feature')
* match responseStatus == 200
GET API By Reference >> /sending/v1/dm?ref={ref}
* call read('classpath:../RetrieveByRefAbstract.feature') {ref: #(tranRef)}
* match responseStatus == 200
GET API By Id>> /sending/v1/dm/{id}
* call read('classpath:../RetrieveByIdAbstract.feature') {id: #(pmId)}
* match responseStatus == 200
抽象特性使用url关键字来调用api
MySimulation.scala看起来像这样
class MySimulation extends Simulation {
val protocol = karateProtocol(
"/sending/v1/dm?ref={ref}" -> Nil,
"/send/v1/dm/{id}" -> Nil,
"/sending/v1/dm" -> Nil
)
protocol.nameResolver = (req, ctx) => req.getUrlAndPath()
val create = scenario("create").exec(karateFeature("classpath:com/mastercard/send/xb/Testcases/Rem1Shot/Remit1ShotWithFrwdFeesRetrieve.feature"))
setUp(
create.inject(rampUsers(2) during (5 seconds)).protocols(protocol)
)
}
现在的问题是,在报告中,使用{id}的GET请求和POST请求被聚合,但是使用ref的GET请求被单独报告
我也尝试过在getUrlAndPath中使用nameResolver,但仍然没有成功
我不确定我是否遗漏了什么
注:
还有一个问题,我无法使用下面的协议聚合id为的GET请求,但现在当我包含完整uri时,就可以了
"/dm/{id}" -> Nil,
"/dm" -> Nil
对于该get请求,传递一个假头并使用它来控制nameResolver: 我本以为
/sending/v1/{dm}
或类似的东西会起作用
请注意,理论上,您可以编写一些自定义Scala代码来解析URL并进行名称解析。如果您觉得这应该变得更容易,请提交一个功能请求,或者更好的是,贡献代码 这对我来说太多了,如果没有其他人帮助,请遵循以下流程:谢谢!这个解决方案对我有效。但经过进一步调试,我能够通过在GET抽象文件中添加param关键字来解决这个问题。最初,形成完整的url,存储在变量中,并使用url关键字传递。