1

While using Karate framework for API testing I am trying to call a method in one feature file from other like this:

    Scenario: Scenario description
  * def util = callonce read('UtilFunctions.feature')
  * def object = 
  """
    {"_yearsOffset":-20, "_daysOffset":0}
  """
  * def customerAge = call util.getDate(object)
  * print customerAge

The method just returns a date with a yearsOffset and daysOffset to move the date if desired.

When I execute this I have the following error:

not a callable feature or js function: [type: STRING, value: 30.03.2002]

Even though the value displayed in the log is correct and does what the function is asked to do, the execution fails.

Any guess? I am running out of ideas.

1

1 Answer 1

1

Here's a guess, you don't need to use call when simply invoking a function:

* def customerAge = util.getDate(object)

The call makes things a little bit easier to read only if it is a function

* def fun = function(x){ return { foo: x } }
* def customerAge = call fun 'bar'
# this will also work
# def customerAge = fun('bar')
Sign up to request clarification or add additional context in comments.

Comments

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.