Unable to use read('classpath:') when running tests with standalone karate.jar

I am attempting to execute my tests using the karate stand-alone jar. Throughout my project, I use the read('classpath:') when locating files.

However, when I attempt to execute my tests from the CLI, I receive the following error:

src.test.java.Users.getUser: -unknown-:6 - javascript evaluation failed: read('classpath:commonUtils.feature'), java.io.FileNotFoundException: commonUtils.feature (The system cannot find the file specified) Command: java -jar -Dkarate.config.dir="src/test/java" karate.jar -e DEV -t @tests src/test

It seems that I will have to declare the classpath on execution, would you be able to provide some insight on how to do this please? I'm not sure whether my issue is linked to [karate][standalone] Error : could not find or read file


Solution 1:

Can you try the ZIP release and if you open the karate batch file you will see this:

java -cp karate.jar:. com.intuit.karate.Main $*

So the trick to setting a custom classpath is to use the com.intuit.karate.Main entry point and in the above example the current dir is also added to the classpath.

It would be great if you try the current RC version (0.9.5.RC3) to ensure we have everything working as expected.

For more information, see this part of the docs: https://github.com/intuit/karate/tree/develop/karate-netty#custom-classpath