1

I am trying to configure a cucumber in maven project in eclipse. unfortunately facing issue in runner class. I had created .feature, stepDefinition.java and ,testrunner files respectively. I had tried with all the possible dependencies in my pom.xml but still the problem persists. please dont mark it as a duplicate as none of the solution works for me.

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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>cucumberFramework</groupId>
  <artifactId>cucumberFramework</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>cucumberFramework</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <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-jvm</artifactId>
            <version>1.2.5</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>

        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.5.3</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>


</dependencies> 
</project>

testRunner.java

package runner;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions; //shows error as The import cucumber.api cannot be resolved
import cucumber.api.junit.Cucumber;//shows error as The import cucumber.api cannot be resolved


    @RunWith(Cucumber.class)// shows error as Class<Cucumber> cannot be resolved to a type
    @CucumberOptions( //shows error as CucumberOptions cannot be resolved to a type
            features = {"features"} //the path of the feature files
            ,glue={"stepDefinitions"}
            )//the path of the step definition files

    public class testRunner{ 

    }
muthu
  • 541
  • 3
  • 16

1 Answers1

0

There could be 3 possible reasons for this issue:

  1. You might have missed building your project. Try running the following maven commands for your project in specific order(Run As-> 6 Maven build...-> in "Goals" add the commands) a) clean install -U b) eclipse:clean c) eclipse:eclipse
  2. Your internet connection in eclipse might not working properly. For this issue please refer: Eclipse cannot connect to internet

  3. Your maven "settings.xml" is incorrect.