Java: Package Cucumber. Api. Junit Does Not Exist

Java: Package Cucumber. Api. Junit Does Not Exist

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="" xmlns:xsi=""
  xsi:schemaLocation=" ">
    <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>
  <dependencies>
      <!--  -->
      <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>
    <!--  -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java8</artifactId>
        <version>1.2.5</version>
    </dependency>
      <!--  -->
      <dependency>
          <groupId>info.cukes</groupId>
          <artifactId>cucumber-core</artifactId>
          <version>1.2.5</version>
          <scope>test</scope>
      </dependency>
      <!--  -->
      <dependency>
          <groupId>info.cukes</groupId>
          <artifactId>cucumber-junit</artifactId>
          <version>1.2.5</version>
      </dependency>

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

3 Answers

I don't know if you already resolved your issue but you can quickly fix it by removing the scope tags from your pom.xml file. Do this action for all dependencies that you are facing issues and should work fine.

Cheers, HH

2

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

4

Change the imports.

instead of: import cucumber.api.junit.Cucumber;

use import io.cucumber.junit.Cucumber;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.