Home > Mobile >  Karate ReferenceError: package is not defined
Karate ReferenceError: package is not defined

Time:06-02

I'm using java codes in karate feature file, refering github demo:

Background:
* url demoBaseUrl
* def JavaDemo = Java.type('com.intuit.karate.demo.util.JavaDemo')

I noticed that the feature file is in src/test/java, which defined as classpath in pom.xml. Meanwhile the util class is in src/main/java.

In my project I use similar structure

enter image description here

Following code is in the feature file with Class Reference:

    * def XMLValidator = Java.type(base.utility.XMLValidator)
    * def validator = new XMLValidator()

But I got an exception below:

org.graalvm.polyglot.PolyglotException: ReferenceError: "base" is not defined

Is it a classpath problem?

CodePudding user response:

Aren't you missing the quotes (for a string argument to Java.type()

* def XMLValidator = Java.type('base.utility.XMLValidator')
  • Related