Problem with passing config as part of karate.callSingle()
See original GitHub issueHello there, As described on stackoverflow issue I am getting unexpected errors when trying to pass a config item to a feature file I call from callSingle() in karate-config.js.
Error I’m getting:
mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject version
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myproject ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/flisowski/karate/myproject/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/flisowski/karate/myproject/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myproject ---
[INFO] Surefire report directory: /Users/flisowski/karate/myproject/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running examples.ExamplesTest
16:41:20.026 [main] INFO com.intuit.karate - karate.env system property was: null
16:41:20.036 [main] INFO com.intuit.karate - >> lock acquired, begin callSingle: classpath:examples/users/users.feature
16:41:20.041 [main] ERROR com.intuit.karate - javascript function call failed: unexpected feature call arg type: class jdk.nashorn.internal.scripts.JO4
16:41:20.042 [main] ERROR com.intuit.karate - failed function body: function() {
var env = karate.env; // get system property 'karate.env'
karate.log('karate.env system property was:', env);
if (!env) {
env = 'dev';
}
var config = {
env: env,
myVarName: 'someValue'
}
if (env == 'dev') {
// customize
// e.g. config.foo = 'bar';
} else if (env == 'e2e') {
// customize
}
//// That works
// var result = karate.callSingle('classpath:examples/users/users.feature');
//// That does not
var result = karate.callSingle('classpath:examples/users/users.feature', config);
karate.log(result);
return config;
}
16:41:20.042 [main] ERROR com.intuit.karate - evaluation of 'karate-config.js' failed: javascript function call failed: unexpected feature call arg type: class jdk.nashorn.internal.scripts.JO4
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.782 sec <<< FAILURE!
examples.ExamplesTest Time elapsed: 0.781 sec <<< ERROR!
java.lang.NullPointerException
at com.intuit.karate.core.ScenarioExecutionUnit.init(ScenarioExecutionUnit.java:147)
at com.intuit.karate.core.ScenarioExecutionUnit.run(ScenarioExecutionUnit.java:236)
at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:164)
at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:73)
at com.intuit.karate.junit4.Karate.runChild(Karate.java:125)
at com.intuit.karate.junit4.Karate.runChild(Karate.java:56)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at com.intuit.karate.junit4.Karate.run(Karate.java:133)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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:483)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Results :
Tests in error:
examples.ExamplesTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.305 s
[INFO] Finished at: 2019-07-04T16:41:20+01:00
[INFO] Final Memory: 17M/254M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project myproject: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/user/karate/myproject/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Problem with passing config as part of karate.callSingle() #817
As described on stackoverflow issue I am getting unexpected errors when trying to pass a config item to a feature file I call...
Read more >Problem with passing config as part of karate.callSingle()
As the title says I'm experiencing issues when trying to pass a config item to the feature file I call from callSingle() in...
Read more >Karate | Test Automation Made Simple.
This can be achieved using karate.callSingle() . A common requirement is to pass dynamic parameter values via the command line, and you can...
Read more >karate.callSingle() feature in Karate Framework| Part 14
... the Karate Hooks concept - karate.callSingleAPI Authentication - https://www.youtube.com/watch?v=k-Q-Kywk1O4Karate- config.js - https:/.
Read more >Using Karate-Config.js file to set the configuration variable
Feature file is called using method karate.callsingle.This method makes sure that the passed file is called only once per session.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ptrthomas I’ve updated my maven, and jdk8 to the latest release before I had a chance to try your workaround - it works now. Must have been something to do with the older version, most likely related to the issue you pointed out on stackoverflow. Running same debug, I can see the passed callArg is jdk.nashorn.api.scripting.ScriptObjectMirror.
Thank you for your support!
@flisowski thanks for the update !