Cucumber 选项不是 运行 来自 mvn cli 命令的标签场景

Cucumber option not running the tag scenario from mvn cli command

我想使用以下命令从我的功能文件中 运行 特定场景。

mvn test -Dcucumber.options="--tags @Smoke-Login"

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <includes>
                        <include>**/TestRunner.java</include>
                    </includes>
                    <parallel>methods</parallel>
                    <threadCount>4</threadCount>
                    <useUnlimitedThreads>false</useUnlimitedThreads>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

下面是我的 运行ner 文件,用于 运行ning 套件,来自 pom.xml

@RunWith(Cucumber.class)
@CucumberOptions(
        publish = true,
        features = "classpath:features",glue = "stepDefinations",
        plugin = {"junit:target/cucumber-results.xml","rerun:target/rerun.txt",
                    "pretty",
                    "json:target/cucumber-reports/CucumberTestReport.json"},
        tags="@QA53",
        monochrome = true
)
public class TestRunner {

    @BeforeClass
    public static void setup(){
        String os = System.getProperty("os.name").toLowerCase();
        if (os.contains("mac")) {
            PropertyConfigurator.configure(System.getProperty("user.dir")+"/src/test/resources/log4j.properties");
        }
        else {
            PropertyConfigurator.configure(FileReader.getInstance().getConfigReader().getlog4jpath());
        }
    }

    @AfterClass
    public static void writeExtentReport() {
        String os = System.getProperty("os.name").toLowerCase();
        if (os.contains("mac")) {
        }
        else {
        }
    }
}

下图中是我的文件结构。

如果您在 a recent version of Cucumber (> 5.0) 上,则语法为 cucumber.filter.tags=@Smoke-Login

您应该在 POM 文件中提到的 运行ner 文件中指定此功能文件。并且功能文件应该具有您要执行的场景的标签@Smoke-Login。 然后你将能够 运行 使用以下命令

mvn test -Dcucumber.options="--tags -@Smoke-Login"