Warm tip: This article is reproduced from serverfault.com, please click

maven-Java:程序包cumul.api.junit不存在

(maven - Java: package cucumber.api.junit does not exist)

发布于 2017-03-21 10:25:38

我一直在努力使它起作用。

我想建立一个测试运行器类,像这样

但是我得到这个错误:

错误:(3,26)Java:包 Cucumber.api.junit不存在
错误:(10,10)Java:找不到符号
符号:类Cucumber

该类如下所示:

package nl.prvgld.sigma.aanvraagtitels.testutil;

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
public class RunFeature {
}

Pom.xml看起来像:

<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/maven-v4_0_0.xsd">
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
  <modelVersion>4.0.0</modelVersion>
  <groupId>nl.prvgld.sigma.aanvraagtitels</groupId>
  <artifactId>Aanvraagtitels</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Aanvraagtitels</name>
  <url>http://maven.apache.org</url>
  <dependencies>
      <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>3.2.0</version>
      </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java8</artifactId>
        <version>1.2.5</version>
    </dependency>
      <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
      <dependency>
          <groupId>info.cukes</groupId>
          <artifactId>cucumber-core</artifactId>
          <version>1.2.5</version>
          <scope>test</scope>
      </dependency>
      <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
      <dependency>
          <groupId>info.cukes</groupId>
          <artifactId>cucumber-junit</artifactId>
          <version>1.2.5</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
      <dependency>
          <groupId>com.microsoft.sqlserver</groupId>
          <artifactId>mssql-jdbc</artifactId>
          <version>6.1.0.jre8</version>
      </dependency>
      <dependency>
          <groupId>com.smartbear.readyapi.testserver.cucumber</groupId>
          <artifactId>testserver-cucumber-core</artifactId>
          <version>1.0.0</version>
          <scope>test</scope>
      </dependency>


  </dependencies>
</project>

所有类都在“测试”文件夹下的某个位置。我一直在这里查看一些相关问题,并尝试了一些解决方案,例如从Pom中删除测试,并确保我在Pom中具有junit,cucumber-junit,cucumber-java8和cucumber-core。

我正在使用Intellij。

朝正确方向提供的任何帮助都将受到高度赞赏!

干杯!

Questioner
Chai
Viewed
0
Thomas Sundberg 2017-03-22 15:09:47

通过检查,一切看起来都不错。但显然,它无法按你预期的那样工作。

使用IDEA进行编译和使用Maven进行编译时,是否会遇到相同的错误?

首先,我将从Cucumber团队克隆一个入门项目并使其正常运行。以后对其进行扩展以包含你所需要的东西要容易得多。克隆https://github.com/cucumber/cucumber-java-skeleton并使用Maven使用

mvn clean install

开箱即用。

使用有效的解决方案,请朝着你实际想要的项目迈出几步。