0

So for re usability, how can I reuse some particular amount of code from one feature file to other feature file.

I don't want to keep functions outside in js files.

2 Answers 2

1

As of now, this is not possible with karate.

IMHO, this is not even valid enhancement request. If you really want to reuse the code, it would be better idea to keep outside of feature file in js function and calling them from different feature files as and when needed.

Peter Thomas, author of Karate, mentioned here that reuse of feature is possible and one cannot reuse the particular scenario from feature file.

Sign up to request clarification or add additional context in comments.

Comments

0

I don't want to keep functions outside in js files.

You don't have to. Please read the documentation. There are multiple ways for code-reuse:

2 Comments

Yeah, have read the doc thoroughly. But If i call feature file from other feature file, I can't call some particular block of code. Either i have to divide it in such a way that , there is no more than one funtion in 1 feature file. Or use java.
@AneeshGoel this is by design. you will have 2 types of features - your main tests and the ones that are re-usable that will typically be "sign-in" or "data set-up" flows. stick to this pattern and you will be fine. you seem to be over engineering your tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.