如何从命令行为注释设置新值?

How set new value for the annotation from the command line?

我的任务:运行 从命令行自动测试,将标记名称作为参数传递。

我的class:

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome = true,
        glue = {"com.company.stepDefs", "com.company.stepdefs"},
        features = {"src/test/resources/features/"},
        tags = {"@TEST1"},
        plugin = {"pretty", "html:target/cucumber-html-report"}
)

public class CucumberTest { }

我需要为参数 tags 传递新值。

  1. 在 Java-code 中我需要为这个任务做什么?如何为注释设置新值?

  2. 命令行需要什么命令?

  1. How to set my new value for the annotation?

通过命令行参数。

  1. What command do I need on the command line?

mvn 测试 -Dcucumber.filter.tags="@TEST1"

文档是你的朋友:

https://cucumber.io/docs/cucumber/api/