Search code examples
karateintuit-partner-platform

How to add profile variable in Karate


Currently I am using the following command to run my feature file:

mvn test -Dcucumber.options="--plugin html:target/cucumber-html --tags @dogs" -Dtest=TestParallel.java  -Dkarate.env=Pets

But I wish to add another variable while calling running the command. Something like this:

mvn test -Dcucumber.options="--plugin html:target/cucumber-html --tags @dogs" -Dtest=TestParallel.java  -Dkarate.env=Pets -Dname=Charlie

How can I do that?


Solution

  • You can pass extra dynamic parameters using a combination of Java system-properties and reading karate.properties

    mvn test -Dtest=TestParallel.java  -Dkarate.env=pets -Dmy.name=foo
    

    And then in karate-config.js

    var myName = karate.properties['my.name'];
    

    Or even in any feature file:

    * def myName = karate.properties['my.name']
    

    Kindly do note that -Dcucumber.options="--plugin html:target/cucumber-html" does not have any effect in Karate and will be deprecated in the future.