【问题标题】:Cucumber test failed : Exception in thread "main" java.lang.NoClassDefFoundError: io/cucumber/plugin/SummaryPrinter黄瓜测试失败:线程“主”java.lang.NoClassDefFoundError 中的异常:io/cucumber/plugin/SummaryPrinter
【发布时间】:2020-08-03 02:31:27
【问题描述】:

我试图从 Cucumber 功能文件中执行基本测试,但发现错误:

Exception in thread "main" java.lang.NoClassDefFoundError: io/cucumber/plugin/SummaryPrinter

功能文件:


Feature: Login Action

Scenario: Successful Login with Valid Credentials
    Given User is on Home Page
    When User Navigate to LogIn Page
    And User enters UserName and Password
    Then Message displayed Login Successfully

Scenario: Successful LogOut
    When User LogOut from the Application
    Then Message displayed LogOut Successfully

测试运行文件:


package test;

import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "Feature"
        ,glue={"stepdefinition"}
        )

public class TestRunner {

}

我正在使用 eclipse 并通过 eclipse 市场安装了 cucumber 插件。 谁能帮我解决这个问题?

【问题讨论】:

    标签: selenium-webdriver installation cucumber bdd


    【解决方案1】:
    package cucumberOptions;
    
    import cucumber.api.CucumberOptions;
    import cucumber.api.testng.AbstractTestNGCucumberTests;
    
    //@RunWith(Cucumber.class)
    @CucumberOptions(
            features = "src/test/java/features",
            glue = "stepDefinations")
    public class TestRunner extends AbstractTestNGCucumberTests {
    
    }
    

    请记住,功能 stepDefinations 是同一级别的文件夹,我的 testRunner 类也在一个名为“cucumberOptions”的文件夹内,与其他 2 个文件夹处于同一级别,在我的情况下,它们在 test 内文件夹,因为这是一个类似 maven 的项目

    【讨论】:

      【解决方案2】:

      看起来缺少其中一个 jar 的依赖项。新版本的黄瓜真的很忙而且很麻烦,因为总是有重大变化。从 cucumber 5.1.3 升级到 5.7.0 时,我也看到了同样的错误。花了一些时间后,我通过在 pom 中添加以下附加依赖项来解决它:

      <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-plugin</artifactId>
          <version>5.7.0</version>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 2020-05-26
        • 1970-01-01
        • 1970-01-01
        • 2017-08-08
        • 1970-01-01
        • 2017-10-11
        • 1970-01-01
        • 2019-04-26
        相关资源
        最近更新 更多