简体   繁体   中英

Karate force scenarios inside a feature file to execute sequentially on multiple threads

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"?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM