【发布时间】:2025-12-09 18:20:06
【问题描述】:
我正在做一个关于空手道加特林的 POC,以重复使用我的测试。我已经参考了文档并安装了这些版本。首先,像往常一样出色的工作,非常容易设置和开始。
我正在从 MySimualtion.scala 调用一个特征文件,该文件具有以下三个其他抽象特征调用:
* 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 请求是单独报告的。
我也尝试过将 nameResolver 与 getUrlAndPath 一起使用,但仍然没有成功。
我不确定我是否在这里遗漏了什么。
注意: 还有一个问题是我无法通过使用以下协议来聚合带有 id 的 GET 请求,但现在当我包含完整 uri 时它就可以了。
"/dm/{id}" -> Nil,
"/dm" -> Nil
【问题讨论】:
-
这对我来说太多了,如果没有其他人帮助,请按照此过程:github.com/intuit/karate/wiki/How-to-Submit-an-Issue
标签: karate