Search code examples
testingkarate

karate.callSingle not found .feature file in karate-config.js


I'm using karate v0.9.6, and it's wonderful tool. I have a >1000 scenarios, each of them need to token for work, so i use callSingle in karate-config.js for creating and caching tokens. I use standalone jar file.

Part of my karate-config.js:

  var auth_cfg = { 
  server: env,
  credentials: karate.properties['credentials']};

  var result = karate.callSingle('classpath:credentials/generate_tokens.feature', auth_cfg);

I'm using .sh file like this:

rm -rf target &&
  java -Xmx2048m \
    -Dlogback.configurationFile=cfg/logs_debug.xml \
    -jar \
    -Dcredentials=data.json \
    karate-1.0.1.jar -e https://my-server/ \
    --tags ~fixme \
    --tags ~ignore \
    --threads 4 \
   features/services/simple_plan.feature

And, it's working perfectly on v.0.9.6 long time. But, when I'm try to upgrade to v 1.0 or 1.0.1, a give an error:

org.graalvm.polyglot.PolyglotException: not found: credentials/generate_tokens.feature

I found this issue: https://github.com/intuit/karate/issues/1515

But examples not working for me. I'm trying use "file:" and karate.properties['karate.config.dir'] + '/features/auth/auth.feature'. Always i got an error:

not found: credentials/generate_tokens.feature

Who else has faced this problem?


Solution

  • As you can see in the discussion of #1515 - this is why we'd really like more folks to try the RC versions and give us feedback (we spent months on this) instead of waiting for 1.0.

    Yours seems to be an edge case where you are using the stand-alone JAR and a custom shell script.

    My first suggestion is to use the -w flag. This is a new argument in 1.0 which can set the "current working directory", but it should default correctly in your case.

    The second suggestion is to set the classpath for the JVM. Use this as a reference: https://stackoverflow.com/a/58398958/143475 - and once you do that, classpath: will work as you expect.

    Else please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue - and I have to say that unless you can help us fix this, you may have to remain on 0.9.6 for a while. Sorry.