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

标签 java maven cucumber-jvm

我正在尝试使用 maven 和 junit 运行我的 cucumber 测试。当我使用 cucumber 关键字 @given、@when 等时,它显示的错误为 包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>

最佳答案

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

关于java - 包cucumber.api.java.en 不存在cucumber,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40739443/

相关文章:

java - 我们如何使用 JAVA 在没有外部资源的情况下从推文中删除(或检测)非英语标签

java - HibernateException : Unable to resolve entity name from Class [java. lang.Boolean] 预期的实例/子类

java - 使用 Optaplanner 7.0.0.Final 时出现 ClassNotFoundException org.reflections.Configuration

maven - 我什么时候应该使用多模块 Maven 项目?

cucumber - 功能文件中是否提供其他概念(小 cucumber 语言)?

java - 在类路径 : 上发现多次出现 org.json.JSONObject

java - 如何处理 API 方法抛出的基本异常?

eclipse - 如何在本地构建和运行 Scala Spark

java - 与远程 Restful 服务的集成测试

java - 抑制 Cucumber 报告中的 Java 异常堆栈跟踪