2

I have resources that I don't want them to be included in the project. I want to be able to store them at a shared location and use them from there. Is there any way to do this in karate? Can I specify absolute paths within read function?

None of the below methods work:

* def result = read('C:/Utils/backup.json')

Error: Caused by: java.io.FileNotFoundException: D:\Automation\project\myproject\src\test\java\api\component\mycomp\Utils\backup.json (The system cannot find the path specified)

* def result = read('classpath:C:/Utils/backup.json')

Caused by: com.intuit.karate.exception.KarateFileNotFoundException: file not found: C:/Utils_TP/backup.json, classpath: true

Odin Thunder
  • 3,284
  • 2
  • 28
  • 47
DDana
  • 117
  • 8

1 Answers1

0

Karate will never support this, because this is very very bad practice.

My suggestion is you write a custom Java function to read the file from the path you provide and use it. Refer to the doc on calling Java or Java Interop.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks! The reason for asking this is that I have large files (for example backups of data) that I want to include in another request as multipart file. How can I then make such an upload? – DDana Nov 06 '17 at 12:55
  • easiest is copy these files under `src/test/java` and use `classpath:`, what's the problem ? – Peter Thomas Nov 06 '17 at 12:57
  • @DDana actually Karate 0.7.0 will support this, as of now there is a 0.7.0.RC1 you can try – Peter Thomas Dec 28 '17 at 07:52