Search code examples
bddkarate

Is there a way to set variables in a scenario and use them in another scenario in karate framework?


I get a value in the response by running one of the scenarios and I would like to use that value in the next scenario. Is there a way to set variables in the context of a feature with karate? I know I can call another feature from within the feaure, but I don't want to move that scenario in another feature and do the call.


Solution

  • Please note that having scenarios depend on another is considered a bad practice, and I don't recommend it: https://github.com/intuit/karate#script-structure

    But please refer this section on "hooks": https://github.com/intuit/karate#hooks