如何将 Maven cucumber-jvm junit @CucumberOptions(..) 翻译成 Eclipse 运行 配置
How to translate Maven cucumber-jvm junit @CucumberOptions(..) to Eclipse Run Configuration
我的 RunCukeTest class 看起来像:
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 class。
答案竟然是:
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
最后请注意,功能关键字已完全删除。最后指定的路径(没有关键字)告诉 cucumber-jvm 在哪里可以找到功能文件。
如果你得到任何这样的错误 cucumber-jvm 会给你神秘的错误信息。我以为我会 post 为下一个人节省一两个小时。
顺便说一句,要在 Eclipse 中获取 Maven Build 配置,请单击 运行 > 运行 Configurations... 在左侧窗格中双击 Maven Build。创建默认的 Maven 构建配置。给它起个好名字,然后在目标行粘贴你的干净测试 -Dcucumber.options 行。单击 JRE 选项卡并确保使用正确的 JDK 不会有什么坏处。返回 Main 选项卡,按 Apply,按 运行。它完全覆盖了您的 运行CukesTest(或您命名的任何名称)class 中的 @CucumberOptions 行。 运行 以这种方式进行测试要容易得多,而且您不会将 git 与不必要的本地文件编辑混淆。
我的 RunCukeTest class 看起来像:
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 class。
答案竟然是:
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最后请注意,功能关键字已完全删除。最后指定的路径(没有关键字)告诉 cucumber-jvm 在哪里可以找到功能文件。
如果你得到任何这样的错误 cucumber-jvm 会给你神秘的错误信息。我以为我会 post 为下一个人节省一两个小时。
顺便说一句,要在 Eclipse 中获取 Maven Build 配置,请单击 运行 > 运行 Configurations... 在左侧窗格中双击 Maven Build。创建默认的 Maven 构建配置。给它起个好名字,然后在目标行粘贴你的干净测试 -Dcucumber.options 行。单击 JRE 选项卡并确保使用正确的 JDK 不会有什么坏处。返回 Main 选项卡,按 Apply,按 运行。它完全覆盖了您的 运行CukesTest(或您命名的任何名称)class 中的 @CucumberOptions 行。 运行 以这种方式进行测试要容易得多,而且您不会将 git 与不必要的本地文件编辑混淆。