I created a RunTest class to run my test scenarios using Cucumber with JUnit. To run the tests before, I need to import into my project the RunWith class (@RunWith) and pass as parameter the Cucumber.class. Then, the RunWith parameter of the class recognizes more of the parameter that is passed to it, no. The eclipse displays the message:
Multiple markers at this line - Class can not be resolved to a type. - Cucumber can not be resolved to a type. - The annotation @RunWith must define the attribute value
I'm using Maven to organize my JARS files. Following is the code and error screens.
My POM.XML
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
</dependencies>
My Libraries
I also faced the same issue in IntelliJ idea, When I check in the imported libraries it was like below screenshot.
So I remove scope tag from my import in pom file.Then it worked.
Earlier
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
Fix
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
Now it is working fine
Import the cucumber.api.junit.Cucumber
class. It seems you are using Eclipse IDE, so you can import the classes using the Ctrl+Shift+o
(alphabet 'o' not zero) shortcut.
(Ctrl+Shift+O
is 'Organise Imports', and will add any missing imports, remove any unused ones, and order all of your imports). The command is also found under Source > Organise Imports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With