I have a feature file that require login credentials before testing can happen. In Karate, I added a callonce read(login.feature)
so that the login will only happen once and the credentials can be saved in Karate.
However when I run the same feature file in Karate-Gatling, I run into errors:
18:34:58.325 [GatlingSystem-akka.actor.default-dispatcher-4] INFO com.intuit.karate - >> lock acquired, begin callonce: read('login.feature')
18:34:58.357 [GatlingSystem-akka.actor.default-dispatcher-4] INFO com.intuit.karate - >> lock acquired, begin callonce: read('login.feature')
18:34:58.357 [GatlingSystem-akka.actor.default-dispatcher-4] INFO com.intuit.karate - >> lock acquired, begin callonce: read('login.feature')
================================================================================
2019-05-06 18:34:58 1s elapsed
---- Requests ------------------------------------------------------------------
> Global (OK=0 KO=0 )
---- test1 ---------------------------------------------------------------------
[##########################################################################]100%
waiting: 0 / active: 0 / done: 1
================================================================================
There is a workaround, where I execute the login.feature first, then feed the login token to the other feature files. However, I was wondering if it is just me, or is the callonce
(and possibly call
) function is not supported. I suspect that the Gatling does not wait for the call to return and simply shut the test scenario.
Yeah, remember callonce
is scoped to a feature file.
Use callSingle()
- you can use it in a feature file (instead of karate-config.js
where it is normally recommended) - and that is guarateed to lock across all features and run once.