5

I am only using the latest standalone karate jar to test my API on a docker container configured with JRE and I don't have any Java code.

Currently on one of my features, i have this : read('file.json'), and it works fine when the resource file is on the same directory than the feature file. I know that it is recommended to do this way.

But if i also want to have a central directory with all resource files to avoid duplicatas, it doesn't work even with this command : read('classpath:directory/file.json')

The error is the following :

"[com.intuit.karate.exception.KarateException: could not find or read file: xxx, prefix: CLASSPATH"

I even tried without success to set a classpath on the command line when running the jar : java -cp $CLASSPATH . -jar ~/karate.jar

My question: Is it possible to set a Prefix on Karate with the standalone jar to be able to easily read any file from other directories ?

Maik
  • 3,419
  • 1
  • 23
  • 34
rfjg
  • 115
  • 2
  • 8

1 Answers1

2

Can you try the file: prefix, instead of classpath: it will support absolute or even relative paths from current working directory.

Version 0.8.0 had some bugs with file path handling especially on Windows. So try 0.9.0.RC4 if you get stuck - but do provide feedback on it if possible anyways.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Tried this solution on linux and it doesent seam to work, did I understood well how this works? https://i.imgur.com/HfaiaLp.png @peter-thomas – Dusan Gligoric Nov 14 '18 at 19:39
  • @DusanGligoric sorry unable to make out anything, please refer: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Nov 15 '18 at 01:05