如何将Maven cucumber-jvm junit @CucumberOptions(..)转换为Eclipse运行配置 [英] How to translate Maven cucumber-jvm junit @CucumberOptions(..) to Eclipse Run Configuration

查看:1696
本文介绍了如何将Maven cucumber-jvm junit @CucumberOptions(..)转换为Eclipse运行配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的RunCukeTest类看起来像:

My RunCukeTest class looks like:

package runsupport;

import ....

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome = true,
        features = "classpath:features",
        plugin = {"pretty", "html:target/cucumber-html-report", "json:target/cucumber.json"},
        glue = { "classpath:steps", "classpath:runsupport" },
        tags = {"@search"}
        )
public class RunCukesTest{

}

如何将其转换为mvn test -Dcucumber.options =格式,以便我可以从目标行Maven构建运行配置?我想要更改运行配置上的标签,而不必每次编辑RunCukeTest类。

How do I convert this to mvn test -Dcucumber.options="" format so that I can run it from the Goals line of a Maven Build run configuration? I want to be able to change the tags on the run configuration rather than having to edit the RunCukeTest class each time.

推荐答案

答案原来是:

clean test -Dcucumber.options="--tags @search --monochrome --plugin pretty:STDOUT --plugin html:target/cucumber-html-report --plugin json:target/cucumber.json --glue steps --glue runsupport classpath:features"

请注意,由于我有两个胶合路径,我需要两个--glue语句。另请注意,只指定了两条路径的包名。

Note that since I have two glue paths that I needed two --glue statements. Also note that only the package name of the two -glue paths were specified.

另请注意,STDOUT需要在--plugin上指定:STDOUT。

Further note that STDOUT needed to be specified on --plugin pretty:STDOUT.

最后请注意,feature关键字已完全删除。最后指定的路径(没有关键字)告诉cucumber-jvm在哪里查找功能文件。

Finally note that the feature keyword was dropped completely. The path specified at the end (without a keyword) tells cucumber-jvm where to find the feature files.

如果你得到任何这个错误的黄瓜-jvm给你隐藏错误信息。我以为我会把这个发贴给下一个人,以保存他或她一两个小时。

If you get any of this wrong cucumber-jvm gives you cryptic error messages. I thought that I would post this for the next person to save him or her an hour or two.

BTW,要在Eclipse中获取Maven Build配置,点击Run >运行配置...在左窗格上双击Maven Build。默认的Maven构建配置被创建。给它一个好名字,在目标线上粘贴你的干净的测试-Dcucumber.options行。单击JRE选项卡并确保使用正确的JDK不会受伤。返回主选项卡,按应用,按运行。它完全覆盖了您的RunCukesTest(或任何您命名的)类中的@CucumberOptions行。以这种方式运行测试要容易得多,而且您不会将git与不必要的本地文件编辑混淆。

BTW, to get a Maven Build configuration in Eclipse, click on Run > Run Configurations... On the left pane double-click Maven Build. A default Maven Build configuration is created. Give it a good name and on the Goals line paste your clean test -Dcucumber.options line. It wouldn't hurt to click on the JRE tab and make sure that the correct JDK is being used. Back on the Main tab, press Apply, press Run. It completely overrides the @CucumberOptions line in your RunCukesTest (or whatever you named it) class. It is a lot easier to run tests this way and you aren't confusing git with unnecessary local file edits.

这篇关于如何将Maven cucumber-jvm junit @CucumberOptions(..)转换为Eclipse运行配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆