问题
I am looking for a sample/example gradle project for karate automation. Tried in karate-demo but it didn't helps. Simple skeleton will also helps
回答1:
Please refer to this wiki page: https://github.com/intuit/karate/wiki/Gradle
plugins { id 'java' } ext { karateVersion = '0.9.5.RC4' } dependencies { testCompile "com.intuit.karate:karate-junit5:${karateVersion}" testCompile "com.intuit.karate:karate-apache:${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() }
回答2:
I use VSCode, but with that said, here's my generic Karate tester project build.gradle:
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.testing.TestResult
import org.gradle.api.tasks.testing.TestResult.ResultType
plugins {
id "java"
}
sourceCompatibility = 11
targetCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
def karateVersion = "0.9.6"
testImplementation "com.intuit.karate:karate-junit5:$karateVersion"
testImplementation "com.intuit.karate:karate-apache:$karateVersion"
}
sourceSets {
test {
resources {
srcDir file("src/test/java")
exclude "**/*.java"
}
}
}
test {
testLogging {
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
showCauses true
showExceptions true
showStackTraces true
outputs.upToDateWhen {false}
showStandardStreams true
}
useJUnitPlatform()
systemProperty "karate.options", System.properties.getProperty("karate.options")
systemProperty "karate.env", System.properties.getProperty("karate.env")
}
task karateExecute(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
main = "com.intuit.karate.cli.Main"
}
来源:https://stackoverflow.com/questions/58837152/looking-for-simple-gradle-project-for-karate-automation