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

Java: package cucumber.api.junit does not exist

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

I've been trying to get this to work.

I would like set up a test runner class like so

However I get this error:

Error:(3, 26) java: package cucumber.api.junit does not exist
Error:(10, 10) java: cannot find symbol
symbol: class Cucumber

The class looks like:

package nl.prvgld.sigma.aanvraagtitels.testutil;

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

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

Pom.xml looks like:

<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>

All classes are somewhere under the Test folder. I've been lookin at some related questions here and tried the solutions like removing test from Pom, and making sure I have junit, cucumber-junit, cucumber-java8 and cucumber-core in the Pom.

I am using Intellij.

Any help in the right direction is highly appreciated!

Cheers!

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

By inspection, everything looks good. But obviously, it doesn't work as you expect.

Do you get the same error when compiling with IDEA and compiling with Maven?

To get started, I would clone a getting started project from the Cucumber team and get it working. It is much easier to later extend it to contain the things you need. Clone https://github.com/cucumber/cucumber-java-skeleton and build it using Maven with

mvn clean install

It is expected to work out of the box.

With a working solution, take small steps toward the project you actually would like to have.