我收到错误消息“ Class <Cucumber>无法解析为类型”

时间:2019-08-21 16:12:45

标签: eclipse maven junit automation cucumber

我正在尝试制作一个测试运行器类,但出现错误“类无法解析为类型”

早期的JRE默认设置为1.5,但后来我将其更改为12,因为在某些答案中,它被写成是JRE造成的。

这是我的代码:

package LoginRunner;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "C:\\Users\\abhin\\eclipse-workspace\\FreeCRMBDDFramework\\src\\main\\java\\Features",
        glue = "C:\\Users\\abhin\\eclipse-workspace\\FreeCRMBDDFramework\\src\\main\\java\\LoginStepDef"

        )
public class loginRunner {

}

以下是我添加的依赖项:

<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>FreeCRMBDDFramework</groupId>
  <artifactId>FreeCRMBDDFramework</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>FreeCRMBDDFramework</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.7.1</version>
</dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.7.1</version>
    <scope>test</scope>
</dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>7.0.3</version>
</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/io.cucumber/cucumber-jvm -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-jvm</artifactId>
    <version>4.7.1</version>
    <type>pom</type>
</dependency>
    <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>4.9.0</version>
</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/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.7.1</version>
    <scope>test</scope>
</dependency>

  </dependencies>
</project>

这是我的项目构建路径enter image description here的屏幕截图 这是JAVA编译器设置的屏幕截图 enter image description here

1 个答案:

答案 0 :(得分:0)

黄瓜尚不支持Java12。尝试Java 8。