3

First of all, sorry if I'm asking something obvious as I don't come from a programming background, there I go:

I'd like to run a series of test Scenarios and have declared couple variables in the Background part (I have print them to double check they have been correctly declared), the first one is an integer and the other two strings as you can see.

The problem is that when I try to use them as parameters of the request object, it doesn't seem to work. Is this I want possible? Then, am I doing it wrong? The idea is that I have to change only the Background part for it to apply to all scenarios.

Thanks a lot in advance!

rixoto
  • 33
  • 1
  • 6

1 Answers1

3

I think you have to understand "embedded expressions": https://github.com/karatelabs/karate#embedded-expressions

So this should work:

Background:
* def bar = 'something'

Scenario:
* request { foo: '#(bar)' }
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    Thank you very much, it worked and now I came up another question that I will ask in another thread. I've checked the embedded expressions in the documentation and now I get it a little bit better, a matter of time for me I guess. Thanks again! – rixoto Jan 10 '22 at 12:20