I need to perform two operations on the result of JSON responses.so can we have those different operations inside single JS file? or do we need to have mapping like one JS file for one operation. Please help on this
相关问题
- Karate API Testing - Access variable value across
- Is there a function like call karate.callSingle()
- In Karate, can I update a value for one of the fie
- How to put “OR” operator in Karate API assertion s
- Karate framework symbol encoding in url
相关文章
- How to test each date field in the array response
- Cannot escape url as needed
- want to test assertion of integer value should be
- how to call a sql script or query in background fo
- Passing defined variable through different scenari
- Karate: JsonPath wildcards didn't work or part
- Karate Api Testing - How to pass data from one fea
- Handling JWT bearer token from ADFS
@kmancusi This is how I did a
common.feature
file with my common functions and then the followingmy.test.feature
shows how I import that to use it in another feature.common.feature
my.test.feature
I don't recommend trying to create complicated JavaScript in Karate, it just leads to maintainability issues. If you really want an object with multiple utility methods on it, write a Java class with static methods, and it will be much easier to maintain / debug.
That said, if you really insist - look at this answer: https://stackoverflow.com/a/47002604/143475
But this is what I recommend for most projects. In one "common" feature file, define multiple methods like this:
You can now call this feature like this:
And now all the functions in that feature are available for use: