Search code examples
scalaperformanceperformance-testinggatlingscala-gatling

Gatling dependant scenarios


I have 2 APIs.

  1. Post api to insert data and return unique identifier.
  2. Get api to get inserted data with unique identifier got for first post api.

I have created 2 scenarios. But 2nd scenario not working because I'm not getting actual unique identifier from 1st scenario.

How can I make these two scenarios dependant.


Solution

  • the gatling documentation covers this well - you're after the section on checks.

    So for each request you can store a part of the response in a session variable using

    .check(
      jsonPath("$.someJsonPath").saveAs("id")
    )
    

    after this, whatever was at '.jsonPath' in the response will now be in the session under the key 'id'.

    you can then use this with the gatling DSL methods - for example

    .get("myurl/${id}")