1

I have started working with the karate framework and I am facing a problem:

When I am storing all my api endpoint into one interface file and want to get the endpoint from there, I am not able to get that value.

def api_interface = Java.type('com.intuit.karate.treebo.util.Interfacce_file')
def ai = new api_interface()
def environment_path = ai.environment_path
print environment_path
GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • I tried to improve your question by making it more readable, and fixing formatting, but I think you should A) read [mcve] and then B) further enhance your input. For example by clearly explaining what "I am not getting value" is supposed to mean. Are there errors? If so, include them in your question! – GhostCat Aug 29 '18 at 12:19

1 Answers1

0

There is no need to use Java for this and trust me on this, it will just complicate things. Karate's driving principle is to avoid Java for API testing as far as possible, and if you try to fight this - you will have a bad time.

If you are trying to maintain a list of URL-s that most likely will vary based on your environment, this is exactly what karate-config.js is for.

Most teams are happy with this. But in the rare case that you have a lot of these URL-s - you can store them in JSON format and still initialize them via karate-config.js. Please refer to this other answer which explains this in detail: https://stackoverflow.com/a/49693808/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248