繁体   English   中英

如何将Maven Cucumber-jvm junit @CucumberOptions(..)转换为Eclipse运行配置

[英]How to translate Maven cucumber-jvm junit @CucumberOptions(..) to Eclipse Run Configuration

我的RunCukeTest类看起来像:

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 Build运行配置的目标行中运行它? 我希望能够在运行配置上更改标签,而不必每次都编辑RunCukeTest类。

答案是:

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语句。 另请注意,仅指定了两个-glue路径的软件包名称。

还要注意,需要在--plugin pretty:STDOUT上指定STDOUT。

最后请注意,feature关键字已完全删除。 在末尾指定的路径(不带关键字)告诉Cucumber-jvm在哪里找到特征文件。

如果您遇到任何这种错误,cucumber-jvm都会为您提供一些隐秘的错误消息。 我以为我可以将它发布给下一个人,以节省他一两个小时的时间。

顺便说一句,要在Eclipse中获取Maven Build配置,请单击Run> Run Configurations...。在左窗格中,双击Maven Build。 创建一个默认的Maven Build配置。 给它起一个好名字,在目标行上粘贴干净的测试-Dcucumber.options行。 单击“ JRE”选项卡并确保使用正确的JDK不会有什么坏处。 返回“主要”选项卡,按“应用”,再按“运行”。 它完全覆盖了RunCukesTest(或您命名的任何名称)类中的@CucumberOptions行。 通过这种方式运行测试要容易得多,并且不会将git与不必要的本地文件编辑混淆。

暂无
暂无

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

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