无法在intelliJ中运行简单的黄瓜特征文件

问题描述 投票:0回答:1

我刚刚安装了IntelliJ社区版和Cucumber集成。当我尝试运行功能时,出现以下错误。我该如何解决?我有黄瓜芯4.7.2和小黄瓜7.0.4。

Feature: OrangeHRM Login
  Scenario: Logo presence on OrangeHRM home page
    Given I launch chrome browser
    When I open orangeHRM homepage
    Then I verify that the logo present on page
    And close the browser
Error :
WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/IGherkinDialectProvider
    at io.cucumber.core.options.CommandlineOptionsParser.parse(CommandlineOptionsParser.java:24)
    at io.cucumber.core.options.CommandlineOptionsParser.parse(CommandlineOptionsParser.java:29)
    at io.cucumber.core.cli.Main.run(Main.java:29)
    at cucumber.api.cli.Main.run(Main.java:28)
    at cucumber.api.cli.Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: gherkin.IGherkinDialectProvider
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 5 more

Process finished with exit code 1
intellij-idea cucumber-jvm gherkin
1个回答
0
投票

如@mpkorstanje所述,您在此版本的Cucumber上使用了错误的Gherkin版本。

您不需要自己添加Gherkin依赖项;这可以通过您的构建工具(Maven / Gradle)进行管理。

docs中所述,您仅需要cucumber-javacucumber-java8依赖项。您需要哪一个取决于您是否要分别编写带注释的方法或lambda:

如果要使用lambda表达式API(Java 8)编写步骤定义,请在pom.xml中添加以下依赖项:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java8</artifactId>
    <version>4.7.1</version>
    <scope>test</scope>
</dependency>

否则,要使用带注释的方法编写它们,请将以下依赖项添加到pom.xml:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.7.1</version>
    <scope>test</scope>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.