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.

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
Aneesh Goel
  • 47
  • 2
  • 6

2 Answers2

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.

Amol Chavan
  • 3,835
  • 1
  • 21
  • 32
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:

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 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. – Aneesh Goel May 12 '18 at 06:06
  • 1
    @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. – Peter Thomas May 12 '18 at 06:27