【问题标题】:Cucumber java - Type mismatch: cannot convert from Class<Cucumber> to Class<? extends Runner> error in test runnerCucumber java - 类型不匹配:无法从 Class<Cucumber> 转换为 Class<?扩展 Runner> 测试运行器中的错误
【发布时间】:2016-10-18 14:57:22
【问题描述】:
我正在尝试使用 java 设置 cucumber 框架来运行我的测试,但我在 Test Runner 中遇到类型不匹配错误。
package cucumbertest;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature",
glue={"stepDefinition"}
)
public class TestRunner {
}
这是我的代码
【问题讨论】:
-
-
-
确保您在项目中定义了正确的依赖项:<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.2.4</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> cucumber.io/docs/reference/jvm#junit-runner - 有关基本设置的更多信息
标签:
javascript
selenium-webdriver
cucumber
【解决方案1】:
尝试以下配置:
<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>com.learnautomation.cucumber</groupId>
<artifactId>com.learnautomation.cucumber</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
<scope>test</scope>