由于解决Cucumber选项时出错,因此无法在Cucumber Framework中创建测试Runner类 [英] Unable to create test Runner class in Cucumber Framework due to Error in resolving Cucumber Options
问题描述
我正在为测试自动化创建Cucumber框架.我面临的问题是我无法解决Test Runner类中的CucumberOptions导入
I am working on creating a Cucumber Framework for Test Automation. Issue I am facing is I am not able to resolve the imports for CucumberOptions in the Test Runner class
最初,我尝试使用建议不建议导入的cumming.api.然后,我去了Cucumber的官方网站查找进口商品,但是它们也不能解决问题.
Initially I tried to use the Suggestion of importing cucumber.api which is now deprecated. Then I went to the official Cucumber site to find the imports but they are not solving the problem as well.
不建议使用的导入:
import cucumber.api.CucumberOptions;
从黄瓜官方网站导入:
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
添加上述导入后,我遇到了错误:
After adding the above import I am facing the error :
The import io.cucumber.junit cannot be resolved
下面是Test Runner类中的代码:
Below is the code in the Test Runner class :
@RunWith(Cucumber.class)
@CucumberOptions(features = {"Features"}, glue= {"stepDefinitions"}, dryRun=true)
public class TestRunner {
}
下面是具有所有依赖项的POM结构:
Below is the POM Structure with all the dependencies :
<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>AmazonCucumberFramework</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cobertura/cobertura -->
<dependency>
<groupId>cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>1.8</version>
</dependency>
<!-- 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/io.cucumber/cucumber-java8 -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>4.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>4.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.7.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm-deps -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>4.1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-html -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
我想知道是否需要添加任何新的依赖项.我记得在不建议使用Cucuming.api之前,他曾在黄瓜上工作过,它过去可以正常工作.
I would like to know if there are any new dependencies that need to be added. I remember working on cucumber earlier before cucumber.api was deprecated and it used to work fine.
推荐答案
好,您可以在终端上先尝试mvn clean
然后mvn install -U
,这时您无需使用IDE来确定问题是在IDE中,请使用终端.
Well, you can try mvn clean
and then mvn install -U
on the terminal, at this time you don't use the IDE to make sure the problem isn't in the IDE, use the terminal.
示例pom.xml
: https://github.com/osvaldjr/easy-cucumber/blob/master/pom.xml
导入:cucumber-java, cucumber-junit, cucumber-spring
这篇关于由于解决Cucumber选项时出错,因此无法在Cucumber Framework中创建测试Runner类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!