I am doing a POC on karate-gatling to reuse my tests. I have referred to documentation and installed those versions. First of all awesome work as usual, very easy to setup and get going.
I am calling a feature file from MySimualtion.scala which has three other abstract feature calls as follows:
* 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
Abstract features use url keyword to invoke APIs.
MySimulation.scala looks like this
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)
)
}
Now the issue is, in reports GET request with {id} and POST request is getting aggregated but GET requests with ref are reported individually.
I have also tried using nameResolver with getUrlAndPath, still no luck.
I am not sure if I am missing anything here.
Note: There was another issue where I was not able to aggregate the GET request with id by using following protocol but now its fine when I include full uri.
"/dm/{id}" -> Nil,
"/dm" -> Nil
For that get request, pass a fake header and use that to control the nameResolver: https://github.com/intuit/karate/tree/master/karate-gatling#nameresolver
I would have expected /sending/v1/{dm}
or something like that to work.
Note that in theory you can write some custom Scala code to parse the URL and do the name resolution. If you feel this should be made easier, submit a feature request, or better still, contribute code !