gpt4 book ai didi

java - 如何让 gradle 和 cucumber 一起工作?

转载 作者:行者123 更新时间:2023-11-30 10:52:25 26 4
gpt4 key购买 nike

让 gradle 干净地与 cucumber 一起工作是一个挑战。我想获取 gradle build 来编译和运行测试,但到目前为止我还没有成功。

build.gradle

plugins {
id "com.github.samueltbrown.cucumber" version "0.9"
}
apply plugin: 'java'
apply plugin: 'idea'


def JAVA_WEBSOCKET_VERSION = '1.2.1'
def CUCUMBER_VERSION = '1.2.4'
jar {
manifest {
attributes 'Implementation-Title': 'Java-WebSocket',
'Implementation-Version': JAVA_WEBSOCKET_VERSION
}
}

repositories {
jcenter()
}

dependencies {
testCompile "info.cukes:cucumber-java:$CUCUMBER_VERSION"
testCompile "info.cukes:cucumber-junit:$CUCUMBER_VERSION"
testCompile 'junit:junit:4.+'
}

task wrapper(type: Wrapper) {
gradleVersion = '2.9'
}

目前,我收到很多关于 cucumber 使用的注释(@Given@Then@After)的错误。我想要的是在不使用 JavaExec 的情况下干净地构建项目。这是可能的还是对 gradle 或 cucumber 有特定的限制来阻止这种情况?

最佳答案

dependencies {

testCompile 'info.cukes:cucumber-jvm:1+'
testCompile 'info.cukes:cucumber-jvm-deps:1+'
testCompile 'info.cukes:cucumber-java:1+'
testCompile 'info.cukes:cucumber-junit:1+'
testCompile 'info.cukes:cucumber-core:1+'

}

我创建了另一个函数来执行测试

test { 

ignoreFailures = true


// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true

// set heap size for the test JVM(s)
minHeapSize = "128m"
maxHeapSize = "512m"

// set JVM arguments for the test JVM(s)
jvmArgs '-XX:MaxPermSize=256m'

// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}


// explicitly include or exclude tests( Add Package directly)
exclude "com/**/***/rest/junit**"
exclude "com/**/***/db/junit**"

reports.junitXml.enabled = false
reports.html.enabled = false
}

现在从命令行调用这个函数来执行测试

task "forceTest" { 
dependsOn "clean", "cleanTest", "test"
}

关于java - 如何让 gradle 和 cucumber 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34355584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com