包 cucumber.api.java.en 不存在 cucumber

问题描述 投票:0回答:3

我正在尝试使用 Maven 和 junit 运行我的黄瓜测试。当我使用黄瓜关键字@given、@when等时,它显示错误,因为package cucumber.api.java.en不存在。我尝试使用 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>
java maven cucumber-jvm
3个回答
0
投票

尝试@When、@Given。大写字母很重要。


0
投票

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


0
投票

在我的项目中,我用它更新了 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>
© www.soinside.com 2019 - 2024. All rights reserved.