Stephen
Stephen

Reputation: 93

package cucumber.api.java.en does not exist cucumber

I am trying to run my cucumber tests with maven and junit. When i use the cucumber keywords @given, @when etc., it is showing error as package cucumber.api.java.en does not exist. I tried with maven version 3.3.9 and below is my pom.xml. I don't know whether it is a dependency mismatch or anything else. Can any one help me in this.

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>

Upvotes: 4

Views: 18444

Answers (3)

Rose8525
Rose8525

Reputation: 109

In my project I updated POM.XML with this and it's works:

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

Upvotes: 0

Aditya Anand
Aditya Anand

Reputation: 9

Place your TestRunner.java class and the step definitions under src/test/java directory and feature files under src/test/resources directory

Upvotes: 0

MikeJRamsey56
MikeJRamsey56

Reputation: 2829

Try @When, @Given. Capitalization is important.

Upvotes: 0

Related Questions