Skip to content

Debug Server

Peter Thomas edited this page Oct 16, 2023 · 44 revisions

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.

karate-debugserver

⚠️ This extra dependency is optional - but required for IDE debugging support in Karate 1.4.1 onwards. Debugging is supported only in the Pro version of the Karate Labs IDE plugins for IntelliJ and VS Code.

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>

IntelliJ

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.

VS Code

Using the debug server in VS Code depends on how you are using Karate.

VS Code Bundled

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.

VS Code and Standalone JAR

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.

VS Code and Maven

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.

VS Code and Gradle

If using VS Code and Gradle, you can define a task to do this:

task karateDebug(type: JavaExec) {
    classpath = sourceSets.test.runtimeClasspath
    main = 'com.intuit.karate.Main'
}

And then you can use the "Run Mode Custom" to hook up debugging from VS Code.