Skip to content
Peter Thomas edited this page Feb 1, 2021 · 15 revisions

Here is a simple build.gradle for Karate and JUnit 5. Please also refer to the main README. You can also find a standalone project within the Karate source code here: jobserver.

Also see other references such as this one.

plugins {
    id 'java'
}

ext {
    karateVersion = '1.0.0'
}

dependencies {
    testCompile "com.intuit.karate:karate-junit5:${karateVersion}"
}

sourceSets {
    test {
        resources {
            srcDir file('src/test/java')
            exclude '**/*.java'
        }
    }
}

test {
    useJUnitPlatform()
    systemProperty "karate.options", System.properties.getProperty("karate.options")
    systemProperty "karate.env", System.properties.getProperty("karate.env")
    outputs.upToDateWhen { false }
}

repositories {
    mavenCentral()
    // mavenLocal()
}

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

The optional karate task makes it easier to connect tools such as the Visual Studio Code IDE and use the dedicated Karate extension.

For example, to start the Karate Debug Server:

gradle karate --args='-d'

Gatling

It is possible to use the Karate Gatling integration with Karate by using a custom JavaExec task as shown above. Refer to the documentation here.