无法解析导入cumul.api.junit

时间:2019-04-30 19:03:31

标签: maven selenium cucumber bdd cucumber-junit

我正在使用Cucumber-BDD框架,在其中我在POM.xml中添加了所有必需的Maven依赖项。 但是我无法导入Cucumber.class。我收到以下错误 “无法解析导入的cucumber.api.junit”

  1. 我尝试从BuildPath-> Libraries中手动添加JUNIT jar
  2. 我尝试使用CTRL + SHIFT + T,但看不到Cucumber.api.junit匹配项添加相同内容。
  3. 在“ Maven依赖项”项目文件夹下,我可以看到添加了cumulan-junit-4.3.0.jar

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

  <name>BDDFramework</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.3.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-jvm</artifactId>
    <version>4.3.0</version>
    <type>pom</type>
</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.3.0</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/net.masterthought/cucumber-reporting -->
<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>4.6.0</version>
</dependency>


<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>4.3.0</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>6.0.17</version>
</dependency>

    <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
             <version>3.141.59</version>
         </dependency>   

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.3.0</version>
    <scope>test</scope>
</dependency>

  </dependencies>
</project>

预期-导入Cucumber.api.junit.Cucumber 实际-无法解析导入的cumul.api.junit

2 个答案:

答案 0 :(得分:1)

请删除黄瓜芯黄瓜-jvm-deps 小黄瓜 Junit 。它们是可传递的依赖项,将由您的依赖项提供,然后运行mvn clean install并在IDE中重新导入您的项目。(您可以在下面的依赖项中添加)

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.3.0</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.3.0</version>
    <scope>test</scope>
</dependency>

答案 1 :(得分:0)

删除cuming.api导入并尝试:

import io.cucumber.java.*;

使用最新版本的io.cucumber: 5.4.1