Reputation: 94
I am using the Runner class to execute feature files using java. As far as I can see in the class implementation, I can either run multiple feature files in parallel (Runner.parallel()
) or run individual feature files (Runner.runFeature()
).
As much as I have explored, Runner.runFeature()
is capable of passing objects defined in java to feature files, but not capable of running multiple feature files at once and also, running a set of specific @tags (or not that I'm aware of how it can be done). Whereas, Runner.parallel()
can execute multiple feature files at once and also provides capability of providing @tags to be executed, but java objects cannot be passed as feature file parameters.
Is there a way by which I can pass feature file parameters from java (in the form of json objects) as well as execute only a set of @tags through java invocation?
I have used v1.0.1 so far.
Upvotes: 2
Views: 1151
Reputation: 58058
No you can't. Karate is designed so that anything you want to "initialize" can be loaded within the feature file or in the karate-config.js
for more "global" things.
If you want examples, see the docs for log-masking: https://github.com/intuit/karate#log-masking - that shows how you can load a Java class. You can pass parameters and make this "global", it is up to you.
One hint - any Java singleton you init outside of Karate for e.g. in the JUnit runner can be accessed at any time from any feature file via Java interop.
Feel free to contribute code to Karate to improve it if needed.
Upvotes: 1