首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让gradle和cucumber协同工作?

如何让gradle和cucumber协同工作?
EN

Stack Overflow用户
提问于 2015-12-18 20:19:49
回答 2查看 2.6K关注 0票数 4

让gradle干净利落地使用黄瓜是一项挑战。我想让gradle build编译并运行测试,但到目前为止还没有成功。

build.gradle

代码语言:javascript
复制
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是否有特定的限制来阻止这一点?

EN

回答 2

Stack Overflow用户

发布于 2015-12-19 00:21:02

代码语言:javascript
复制
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+'

}

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

代码语言:javascript
复制
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
}

现在从命令行调用此函数以执行测试

代码语言:javascript
复制
task "forceTest" { 
    dependsOn "clean", "cleanTest", "test"
}
票数 1
EN

Stack Overflow用户

发布于 2016-11-30 11:58:14

请在您的build.gradle文件中使用下面的gradle黄瓜插件

插件{ id 'java‘id "com.github.samueltbrown.cucumber“版本"0.9”}

依赖{ testCompile组:'junit',名称:'junit',版本:'4.11‘编译'org.codehaus.groovy:groovy:2.4.7’cucumberCompile 'info.cukes:cucumber-groovy:1.2.2‘}

在终端中运行gradle cucumber将帮助您开始

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34355584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档