Reputation: 179
Yes, we can "select" a single Scenario by appending a "tag selector" at the end of the feature-file you are calling.
question
However, do we support calling specific scenario with @tag in feature files using the Java API?
Map<String, Object> result = Runner.runFeature(getClass(), "from-java.feature", args, true);
It seems "Runner.runFeature" only supports feature files without @tag
Upvotes: 1
Views: 816
Reputation: 111
Unfortunately, I cannot confirm that Runner.runFeature()
works with the first signature mentioned above (Runner.runFeature("classpath:demo/java/from-java.feature@tag01", args, true);
), at least not in Karate-Gatling 1.4.0. All Scenarios in that Feature file are executed (I'm not sure if at once or sequentially). So I'm forced to spread my Scenarios over several Feature files, which seems not very consistent compared to the other call methods in Karate.
In my case I want to use Karate Features not only for the actual Gatling load simulation (this is done with exec(karateFeature(...)
, I know) but also for pre- and post-processing. E.g. to run and shutdown Karate mockservers or to provide and reset dynamic feeders programmatically. It would be nice if I could keep my code needed for such things in single Feature files with multiple Scenarios.
Upvotes: 0
Reputation: 58098
You are the first person ever to ask for this and I just made this commit.
I leave it to you to test and if it doesn't work you can contribute code. Please refer to the Developer Guide if needed.
My honest opinion based on your questions is you are trying to use Karate for things it is not designed for. Karate is a testing framework.
So maybe you should look at the new Java API because it makes some of the features available in different ways: https://github.com/intuit/karate/wiki/1.0-upgrade-guide#java-api
Upvotes: 1