1

When running all of my feature files, through bamboo/maven, using the "clean test" command, how do I force the scenarios inside each feature file to run in order? On multiple threads. For example, if I have 100 feature files, with 20 scenarios in each feature file, when I run them on with 5 threads, the order of the feature files doesn't matter, feature 10 can run before feature 15, but the scenarios inside of each feature have to run in sequential order. I need to run feature 10 scenario 1, then feature 10 scenario 2, and so on.

So with 5 threads:

thread 1 can run feature 1

thread 2 can run feature 10

thread 3 can run feature 3

thread 4 can run feature 2

thread 5 can run feature 4

But I need each scenario 1 through 20, to execute in order.

So with 5 threads:

thread 1 feature 1 scenario 1, then scenario 2, then scenario 3, ext.

thread 2 feature 10 scenario 1, then scenario 2, then scenario 3, ext.

thread 3 feature 3 scenario 1, then scenario 2, then scenario 3, ext.

thread 4 feature 2 scenario 1, then scenario 2, then scenario 3, ext.

thread 5 feature 4 scenario 1, then scenario 2, then scenario 3, ext.

Is @parallel=false the answer? Do I really need to add that to the top of every single feature file. Like I said I could have 100 feature files in my repository, maybe more. Or do I have to add @parallel=false on the command line? If so, would it be like the other options, "-Dparallel=false"?

Corey Snow
  • 225
  • 2
  • 15

1 Answers1

1

If your Scenario-s are written so that they depend on each other, this is a bad-practice. Please read: https://stackoverflow.com/a/46080568/143475 very carefully.

So yes, Karate does not support a "global" switch to enable the behavior you describe. And one of the reasons is to discourage bad practices.

You will have to add @parallel=false for all features. Even this may not have the desired effect you want in the 1.0 version, because of some behavior changes: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks @Peter Thomas. The scenarios don't necessarily depend on each other, as I know that's bad practice, but I'm seeing errors when running multiple threads where as on a single thread there's no errors. That's why I wanted to force each feature file to run the scenarios in sequential order. If I add @parallel=false to all feature files, do I have to add anything to the command that's running these? – Corey Snow Mar 12 '21 at 13:57
  • @CoreySnow no you don't. from experience, if you leave these mysterious problems as-is it just prolongs your headaches. also note that if you are calling java code, a common mistake is if that code is not thread-safe you can get these "errors". I have no other suggestions except to invest time and understand why your tests are not thread-safe. it is unlikely to be a karate issue as it is reasonably well tested in the wild – Peter Thomas Mar 12 '21 at 14:30