How to debug through a karate testing project using Maven?

删除回忆录丶 提交于 2021-02-05 08:06:28

问题


Is there a way I can debug through the test in a similar way that I would debug a Java app using Maven? For example, if I set breakpoint in the implementstion of step and click on debug with next parameters of CL: mvn clean test -Dkarate.options="--tags ~@ignore" -Dtest=MainRunner -DforkCount=0

and I'm getting next errors:

[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ karateSberApi ---
[WARNING] useSystemClassloader setting has no effect when not forking
[INFO] Running examples.MainRunner
before all
get credentialsMap by cmd
19:27:39.169 [main] INFO  com.intuit.karate.RunnerOptions - found system property 'karate.options': --tags ~@ignore
after all
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.875 s <<< FAILURE! - in examples.MainRunner
[ERROR] testAll  Time elapsed: 0.872 s  <<< ERROR!
java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/ScriptObjectMirror
Caused by: java.lang.ClassNotFoundException: jdk.nashorn.api.scripting.ScriptObjectMirror

I tried to run next and it's working:

public static void main(String[] args) throws ScriptException {
        ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
        engine.eval("print('Hello World!');");
    }

What's wrong? env:

Intellij Idea 2019.3
Bundled (Maven 3) version 3.6.1

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

thanks for your answers!


回答1:


Just use the Visual Studio Code extension / Karate Runner: https://github.com/intuit/karate/wiki/IDE-Support#vs-code-karate-plugin

Video here: https://twitter.com/KarateDSL/status/1167533484560142336



来源:https://stackoverflow.com/questions/59953232/how-to-debug-through-a-karate-testing-project-using-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!