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

10,448

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

Share:
10,448
Stephen
Author by

Stephen

Updated on August 02, 2022

Comments

  • Stephen
    Stephen over 1 year

    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>
    
  • Stephen
    Stephen over 7 years
    Thank you Mike, I am able to solve this issue by placing my stepdefs file in test folder under src.
  • bonh
    bonh almost 5 years
    @Stephen would you be willing to add your comment as an answer and accept it? I made the same mistake -- I put the step definitions under src/main/java instead of src/test/java.
  • hjr2000
    hjr2000 over 3 years
    Thankyou @Aditya, I had an old Maven project which wasn't set up correctly and this helped me out.