java 您访问的页面不存在!

r8xiu3jd  于 2023-04-19  发布在  Java
关注(0)|答案(3)|浏览(146)

我正在尝试使用maven和junit运行cucumber测试。当我使用cucumber关键字@given,@when等时,它显示错误package cucumber.API.java.en does not exist。我尝试使用maven版本3.3.9,下面是我的pom.xml。我不知道是否是依赖项不匹配或其他原因。有人可以帮助我吗?

pom.xml:

<dependencies>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>gherkin</artifactId>
        <version>2.12.2</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <!-- <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <type>maven-plugin</type>
    </dependency> -->
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>3.3.9</version>
    </dependency>
</dependencies>

 <build>
    <plugins>
        <plugin>
            <artifactId>
                maven-compiler-plugin
            </artifactId>
            <version>3.5.1</version>
            <!-- <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <encoding>UTF-8</encoding>
            </configuration> -->
        </plugin>
    </plugins>
</build>
dphi5xsq

dphi5xsq1#

试试@When,@Given。大写很重要。

xbp102n0

xbp102n02#

将TestRunner.java类和步骤定义放在src/test/java目录下,将特性文件放在src/test/resources目录下

bmp9r5qi

bmp9r5qi3#

在我的项目中,我用这个更新了POM.XML,它可以工作:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>CucumberBasic</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.3</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.3</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>

相关问题