Reputation: 73
In my testrunner class, on using @CucumberOptions
, I am getting an error message saying "CucumberOptions cannot be resolved to a type". I am using the latest version of eclipse cucumber dependencies. I have tried every possible way by installing and uninstalling eclipse, by lowering the cucumber dependencies version.
My runner class is :
import org.junit.runner.RunWith;
import cucumber.api.junit.*;
import cucumber.api.testng.AbstractTestNGCucumberTests;
@RunWith(Cucumber.class)
@CucumberOptions(
// format = {"pretty","html:target/html/" } ,
features = "src/test/resources", glue = "com.cucumber.bhsibase.party.tests")
public class TestRunner extends AbstractTestNGCucumberTests {
}
And my 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>BHSI_BASE</groupId>
<artifactId>BHSI_BASE</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BHSI_BASE</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- dependencies added for testng start -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
<!-- dependencies added for testng completed -->
<!-- dependencies on cucumber jarss -->
<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-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<!-- dependencies on log4j jarss -->
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</project>
Please let me know how to proceed ahead with this .
Upvotes: 5
Views: 38747
Reputation: 1
Please Ensure you have cucumber-testng dependency then it works and not org.testng
Upvotes: 0
Reputation: 401
Remove the scope from the dependency. That resolved the issue for me.
<scope>test</scope>
Following should be your dependency
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.3.4</version>
</dependency>
Upvotes: 1
Reputation: 31
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
Most probably both are not getting resolved.
Solution:
Step 1: Change scope of cucumber-junit from test to compile.
Step 2: In your Test runner class
Import Below:
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
Instead of :
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
Working for me
Upvotes: 3
Reputation: 3
Try using this dependency: tech.grasshopper extentreports-cucumber6-adapter 2.1.0
Upvotes: 0
Reputation: 696
I am currently working with Cucumber (it's end of Nov, 2021 and I believe that the version is newer than the answer) and I am following this document. Please also check their skeleton pom file here for the dependencies.
The setup is now use
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/example")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example")
public class RunCucumberTest {
}
and for the @CucumberOptions
, you can use junit-platform.properties
to config.
For more details about the properties configuration, you can find here
I also have an example if you are interested in.
Upvotes: 0
Reputation: 71
This answer is outdated.
Assuming you are either doing a new project or don't rely on any related legacy version code.
Now you need
import io.cucumber.junit.CucumberOptions;
in maven pom.xml, and replace the 7.0.0 to the most recent version.
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
</dependency>
Upvotes: 3
Reputation: 41
I was facing the same issue and resolved the error by including following maven dependency:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
Thanks.
Upvotes: -2
Reputation: 1
This option worked out very well.
Upvotes: -1
Reputation: 1
To Resolve this import - import cucumber.api.CucumberOptions;
add the below maven dependency-
info.cukes cucumber-core` 1.2.5
Upvotes: 0
Reputation: 275
I met the same issue. cucumber-java 1.2.2 is working for me.
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
Upvotes: 6