简体   繁体   English

从Gradle运行单个cucumber-jvm .feature文件

[英]Running Single cucumber-jvm .feature file from Gradle

I am integrating a cucumber-java with an existing gradle java project, that has a focus on test automation. 我正在将Cucumber-java与现有的gradle java项目集成,该项目专注于测试自动化。 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. 我想做的是创建一个gradle任务或一个带有-D属性的单个gradle任务,该属性指定一个运行Cucumber-jvm的Cucumber .feature文件。 All of the examples that I've seen show how to get cucumber-jvm to run as part of the build process. 我所见过的所有示例都显示了如何在构建过程中使黄瓜jvm运行。 Instead, I would like to define a task testCucumber(type: Test) to run a single .feature file. 相反,我想定义一个task testCucumber(type: Test)来运行一个.feature文件。 How would I go about doing this? 我将如何去做呢?

I was able to get this to work by using a javaexec task in gradle. 我可以通过在gradle中使用javaexec任务来使其工作。

 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". 假设所有步骤定义都在名为“ StepDefinitions”的程序包中定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM