Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

[karate][standalone] Error : could not find or read file

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...