Looking for simple gradle project for Karate automation

故事扮演 提交于 2021-02-05 10:43:09

问题


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

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