1

The scenario:

I have java faker set up to create email address for each of my karate tests. example:

    Faker faker = new Faker();
    String email = "people-service." + faker.random().nextInt(0, 100000000)
        + "@mail.com";
    return email;

I run my tests via command line (example: qa-people-service % mvn clean test Dkarate.env=sqa -Dkarate.options="--tags @play"

is there a way I can pass in the environment variable run in the command line into my email addresses? e.g.

String email = "<Dkarate.env>" + "people-service." + faker.random().nextInt(0, 100000000)
        + "@mail.com";
mark quinteros
  • 129
  • 1
  • 7

1 Answers1

1

Yes, if you add -DmyKey=myValue

You can do this anywhere in Karate (feature or JS):

* def myKey = karate.properties['myKey']

Also refer: https://stackoverflow.com/a/52821230/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248