Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

json files and called features not found in jenkins (with Karate Framework)


In my feature I have: * def bar = read('classpath:features/xxx/foo.json')

But when I run tests in Jenkins, I have an error:

java.lang.RuntimeException: javascript evaluation failed: read('classpath:features/xxx/foo.json')
  at com.intuit.karate.Script.evalInNashorn(Script.java:423)
  at com.intuit.karate.Script.evalInNashorn(Script.java:394)
  at com.intuit.karate.Script.eval(Script.java:316)
  at com.intuit.karate.Script.eval(Script.java:194)
  at com.intuit.karate.Script.assign(Script.java:656)
  at com.intuit.karate.Script.assign(Script.java:587)
  at com.intuit.karate.StepDefs.def(StepDefs.java:265)
  at ?.* def u = read('classpath:features/xxx/foo.json')(features/XXX/calling.feature:7)
Caused by: com.intuit.karate.exception.KarateFileNotFoundException: file not

found: features/xxx/foo.json, classpath: true at com.intuit.karate.FileUtils.readFileAsString(FileUtils.java:104) at com.intuit.karate.FileUtils.readFile(FileUtils.java:80) at jdk.nashorn.internal.scripts.Script$Recompilation$8$15A$^eval_.L:1(:3) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117) at jdk.nashorn.internal.scripts.Script$19$^eval_.:program(:1) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at com.intuit.karate.Script.evalInNashorn(Script.java:419) at com.intuit.karate.Script.evalInNashorn(Script.java:394) at com.intuit.karate.Script.eval(Script.java:316) at com.intuit.karate.Script.eval(Script.java:194) at com.intuit.karate.Script.assign(Script.java:656) at com.intuit.karate.Script.assign(Script.java:587) at com.intuit.karate.StepDefs.def(StepDefs.java:265) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at cucumber.runtime.Utils$1.call(Utils.java:40) at cucumber.runtime.Timeout.timeout(Timeout.java:16) at cucumber.runtime.Utils.invoke(Utils.java:34) at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38) at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37) at com.intuit.karate.cucumber.CucumberUtils.runStep(CucumberUtils.java:136) at com.intuit.karate.cucumber.KarateRuntime.runStep(KarateRuntime.java:78) at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44) at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39) at cucumber.runtime.model.CucumberScenario.runBackground(CucumberScenario.java:59) at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:42) at cucumber.runtime.model.CucumberScenarioOutline.run(CucumberScenarioOutline.java:46) at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165) at com.intuit.karate.cucumber.CucumberRunner.lambda$parallel$0(CucumberRunner.java:84) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

`

What is wrong?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

If I understand your question correctly (it severely lacks details), everything works fine on your local machine, but does not work when running on Jenkins.

Don't you have a little bit more stack trace to provide ?

There could be so many possible reasons. Maybe on Jenkins, non-Java files are not being copied correctly to target/test-classes. Check whether the pom.xml on Jenkins is not behaving differently for example because of a Maven profile. You should work with your Jenkins admin / CI team to solve this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...