-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Debug Server
Karate has first-class debug support based on the Debug Adapter Protocol (DAP) standard. The Karate Labs Pro IDE plugins take care of starting a debug session automatically and passing the details of feature files and break-points to the debug server.
The karate-debugserver artifact is available via Maven or Gradle.
All runtime approaches documented below (except "VS Code Bundled") require this extra dependency on the classpath.
Here is the snippet you need for Maven:
<dependency>
<groupId>io.karatelabs</groupId>
<artifactId>karate-debugserver</artifactId>
<version>{karate.debugserver.version}</version>
<scope>test</scope>
</dependency>
With the above extra dependency in place for a Maven or Gradle project, you can debug a Karate test if you are on the Karate Labs Pro version of the IntelliJ plugin.
Using the debug server in VS Code depends on how you are using Karate. Choose from the 4 options below.
If using the bundled Karate runtime in the Pro version of the Karate Labs extension, debugging of feature files should work without any extra setup.
If you are using a version of Karate that is 1.4.1 or greater, you should add the karate-debugserver JAR to the custom classpath. You can download the latest JAR from here.
If you are on the Karate Labs Pro version of the VS Code extension switching the "Run Mode" to Maven should be sufficient to be able to debug a Karate feature file from the Debug
codelens. You will need to add the karate-debugserver dependency to your pom.xml
.
If using VS Code and Gradle, you will need to add the karate-debugserver dependency to your build.gradle
. Then, you can define a task to do this in your build.gradle
:
task karate(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
main = 'com.intuit.karate.Main'
}
This sets up things so that gradle karate --args=-d
on the command-line will start a debug session. In VS Code, use the "Run Mode Custom" to start debugging from VS Code.