1

I've read the documentation (on the subject), but I still don't understand how to do so.

The documentation:

  1. implies that parallel execution is an optional feature ("Karate can run tests in parallel");
  2. implies that I need to write some java code to enable parallel execution, and seems to assume that I'm running karate as part of a java project (e.g. when it says "you refer to the package you want to execute");
  3. gives an example of java code you could write to do so, but the example seems to be particular to using JUnit5, which I'm not using.

My karate features and code are not part of a java project. I run karate independent of any other java (except for a class to override the default logging, as described here). This is why the list items 2 & 3 above don't help me. To further illustrate, here's is how I run my karate tests:

java -Dkarate.env=int -DserviceName=aca-ppa -Dkarate.options="--tags @int" -cp ../jars/karate-1.4.0.jar:. com.intuit.karate.Main *.feature

Do I need to create a .java file like the one shown for JUnit5, compile it and make sure the .class file is in the class path? If so, then:

  1. what would I do about the JUnit5 stuff? I'm not using JUnit5 at present. Do I need it for parallel execution? I rely on, and want the html report that karate produces. Would karate still produce the html report if I specify the JUnit5 stuff?
  2. how would I pass the properties that I need karate to run with? (e.g. the env and my own serviceName property)

Thanks!

Jon Detert
  • 51
  • 4
  • thanks for the feedback, I admit the documentation needs to be improved for non-java teams, and I added a line to the section you linked to. here is some documentation we recently created for non-java teams: https://github.com/karatelabs/karate/wiki/Get-Started:-Other-Runtime-Options – Peter Thomas Aug 18 '23 at 03:23

1 Answers1

1

You just need to pass one more item to karate.options which is --threads or -T which defaults to 1. All the command-line arguments are explained here for those using Karate independent of Java: https://karatelabs.github.io/karate/karate-netty/#usage

So this should work:

java -Dkarate.env=int -DserviceName=aca-ppa -Dkarate.options="--tags @int" -cp ../jars/karate-1.4.0.jar:. com.intuit.karate.Main --threads 5 path/to/my/features

In the next version (1.4.1 onwards) it will be possible to set threads via the karate.options just like tags.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I had tried that, but it doesn't change anything. The output still reports at the end that it used 1 thread: ``` ====================================================== elapsed: 103.76 | threads: 1 | thread time: 101.24 features: 5 | skipped: 0 | efficiency: 0.98 scenarios: 68 | passed: 68 | failed: 0 ====================================================== ``` – Jon Detert Aug 18 '23 at 20:57
  • @JonDetert my apologies, can you try adding this as a "normal" command-line arg as my edit. the `karate.options` is actually a recent feature request that was why I went with that: https://github.com/karatelabs/karate/issues/2373 – Peter Thomas Aug 19 '23 at 07:00
  • 1
    That worked! Thanks for recognizing the problem. You are fantastic! – Jon Detert Aug 21 '23 at 14:13