Karate Gatling callonce/callsingle

86 Views Asked by At

Here is a simple test that I am trying to run:

 Background:
    * def newCatReturned = karate.callSingle('./generate-cat-payload.feature')

  Scenario: Create a new cat
    * print '*** Cat  : ', newCatReturned.cat

    Given path '/cats'
    And request newCatReturned.cat
    When method post
    Then status 201
    And print responseHeaders['Location'][0]

Functional testing works fine. The challenge that I have is during the integrated gatling tests. Though the scenarios are run per the load parameters, the callSingle/callonce are run only once or the cat object returned is same across all invocations of the feaure during the gatling run.

Is there a way to accomplish this so that my PT tests produce different cat object for each iteration of the load? While I could use feeders, I would like to see if there is a single way to randomize payload for both functional and performance tests.

Appreciate any insights.

1

There are 1 best solutions below

4
Peter Thomas On

Just create a Java class with a static method that does what you want. Use that in your Karate feature. For e.g. Utils.getCat()

But using a Gatling feeder is the recommended approach.