【问题标题】:Error running cucumber in eclipse- Could not find or load main class cucumber.api.cli.Main在 Eclipse 中运行黄瓜时出错 - 找不到或加载主类 cucumber.api.cli.Main
【发布时间】:2018-02-24 12:27:07
【问题描述】:

我正在尝试使用 Oxygen.1 运行一个 maven 项目。我安装了黄瓜插件。但是当我运行默认功能文件时,我收到一个错误Error: Could not find or load main class cucumber.api.cli.Main

请帮忙!

【问题讨论】:

标签: eclipse maven cucumber feature-file


【解决方案1】:

我从未使用过 Cucumber,但我想您需要将其作为依赖项添加到您的 Maven pom.xml,如 Cucumber JVM documentation 中所述。

Eclipse 插件增加了语法高亮、内容辅助和其他 IDE 相关的便利。但是您仍然需要告诉 JVM 在哪里可以找到 Cucumber 类,并且在 Maven 项目中,这是由 pom.xml 中的依赖项定义的。

您可以在Cucumber-Eclipse issue tracker 提出功能请求以扩展插件以允许自动将依赖项添加到 Maven 项目。

【讨论】:

    【解决方案2】:

    将这些依赖项添加到 pom.xml 中,问题就会得到解决。我正在尝试使用最新版本,所以遇到了这个问题。当我更改版本时,它对我有用。

    <dependencies>
            <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-java</artifactId>
                <version>2.3.1</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-junit</artifactId>
                <version>2.3.1</version>
            </dependency>
    
    
            <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
            <dependency>
                <groupId>net.masterthought</groupId>
                <artifactId>cucumber-reporting</artifactId>
                <version>3.14.0</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
            <dependency>
                <groupId>info.cukes</groupId>
                <artifactId>gherkin</artifactId>
                <version>2.12.2</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>3.14.0</version>
            </dependency>
            
    </dependencies>
    

    【讨论】:

    • 你好。请下次在代码之外添加解释。它使它更具可读性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-04
    • 1970-01-01
    • 2014-03-28
    • 2014-11-18
    • 2021-02-11
    • 1970-01-01
    • 2019-02-21
    相关资源
    最近更新 更多