0

Cucumber 框架无法识别 @Given/When/Then 注释,但执行工作正常。警告标志将始终显示在功能文件上,并显示“步骤没有匹配的胶水代码”消息。下面是我的 pom.xml 依赖项。

<dependencies>
    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>6.10.3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-testng</artifactId>
      <version>6.10.3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.14.3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>tech.grasshopper</groupId>
      <artifactId>extentreports-cucumber6-adapter</artifactId>
      <version>2.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.aventstack</groupId>
      <artifactId>extentreports</artifactId>
      <version>5.0.4</version>
      <scope>compile</scope>
    </dependency>

如果我从io.cucumber更改为info.cukes,则警告标志将消失。请帮助我了解如何解决此错误

4

1 回答 1

0

请尝试使用这个 POM。不知道你有没有插件。

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.maven</groupId>
    <artifactId>cucumberTesting</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>MyProject</name>

    <properties>
        <cucumber.version>4.1.0</cucumber.version>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <includes>
                        <include>RegressionTestRunner.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>

    </build>

</project>
于 2021-05-07T07:44:56.383 回答