jvm .feature file from Gradle

I am integrating a cucumber-java with an existing gradle java project, that has a focus on test automation. There is no production code within this project, so making the entire project makes little sense.

What I would like to do is to create gradle tasks or a single gradle task with a -D property that specifies a cucumber .feature file to run cucumber-jvm on. All of the examples that I've seen show how to get cucumber-jvm to run as part of the build process. Instead, I would like to define a task testCucumber(type: Test) to run a single .feature file. How would I go about doing this?


I was able to get this to work by using a javaexec task in gradle.

 javaexec {
        main = "cucumber.api.cli.Main"
        classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
        args = ['--plugin', 'junit:target/cucumber-junit-report.xml', '--plugin', 'pretty', '--glue', 'StepDefinitions', 'src/test/Features/FeatureFilename.feature']
    }

This is assuming that all step definitions are defined within a package called "StepDefinitions".

链接地址: http://www.djcxy.com/p/82618.html

上一篇: 将字符串添加到黄瓜功能的Java列表中

下一篇: 来自Gradle的jvm.feature文件