javamavencucumber

Cucumber cannot be resolved to a type. @RunWith(Cucumber.class)


I am trying to execute as a maven project, I have added the dependencies in pom file and in maven dependencies also I can find the cucumber-junit jars. But still I cannot import the appropriate jar. Getting " The import cucumber.api.junit cannot be resolved ". Please find the attached screenshot

Dependency added in maven is

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

enter image description here

Folder structure of TestRunner Class

enter image description here


Solution

  • You have two options

    1- change your folder structure:

    src
      |
      test
         |
         your-package
                    |
                    YourClass
    

    2- You can remove the scope test from the dependency as follows:

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