当前位置: 首页 > 知识库问答 >
问题:

cucumber宁静 “您可以使用下面的代码段实现缺失的步骤”

宗政燕七
2023-03-14

我已经开发了一个带有Serenity-bdd和Cucumber的测试自动化,用于移动测试。我的问题在下面。

TEST PENDING: User can login with credentials
---------------------------------------------------------------------------------

cucumber.runtime.junit.UndefinedThrowable: The step "User launch the app" is undefined

cucumber.runtime.junit.UndefinedThrowable: The step "User sees the login page" is undefined

cucumber.runtime.junit.UndefinedThrowable: The step "User enters asdf@hotmail.com to username input" is undefined

cucumber.runtime.junit.UndefinedThrowable: The step "User enters 123123 to password input" is undefined

1 Scenarios (1 undefined)
4 Steps (4 undefined)
0m0.837s


You can implement missing steps with the snippets below:

**NECESSARY METHODS IMPLEMENTATION** 

虽然我已经实现了这个方法,但是我又得到了这个。我的跑步者,cucumbersteps和特征文件如下。

跑步者:

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/", glue = "cucumbersteps")
public class EbebekRunner {

}

cucumber步:

class LoginSteps {

  @Steps
  EbebekLoginSteps ebebekLoginSteps;

  @Given("^User launch the app$")
  public void user_launch_the_app() {
    ebebekLoginSteps.launchApp();
  }

  @When("^User sees the login page$")
  public void user_sees_the_login_page() {
    ebebekLoginSteps.confirmLoginPage();
  }

  @Then("^User enters (.*) to username input$")
  public void user_enters_to_username_input(String userName) {
    ebebekLoginSteps.enterUserName(userName);
  }

  @And("^User enters (.*) to password input$")
  public void user_enters_to_password_input(String password) {
    ebebekLoginSteps.enterPassword(password);
  }

}

特点:

Feature: Login App

  Background:
    Given User launch the app

  Scenario Outline: User can login with credentials

    When User sees the login page
    Then User enters <username> to username input
    And User enters <password> to password input

    Examples:
      | username         | password |
      | asdf@hotmail.com | 123123   |

我的项目结构如下所述。

在此处输入图像描述

我试着把胶水改成{“cucumber步”},但什么都没有改变。我不明白为什么问题是调用。有人能帮我吗?

共有1个答案

微生城
2023-03-14

老实说,这种类型的错误很棘手,并且可能由于多种原因(例如,将运行器、步骤或功能置于测试文件夹之外)而发生,但是,根据您共享的信息,尝试在路径中添加功能文件的名称:

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/yourfile.feature",
        glue = "stepdefinitions")

如果您在步骤定义文件夹中有一个目录,则必须执行以下操作:

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/yourfile.feature",
            glue = "stepdefinitions/your_directory")
 类似资料:
  • 我正尝试在类似UNIX的命令行上使用Maven运行Cucumber(不幸的是,我被迫使用Windows,尽管cmd.exe具有相同的结果): 结果如下: 我查看了所有Google/SO搜索结果的顶部,以查找此错误信息和类似错误信息。许多例子,例如Cucumber在运行单个特性时找不到步骤,以及Cucumber找不到步骤定义,都说要用和--require参数指定步骤定义,但它们似乎在某个时候从Cuc

  • Java-Cucumber示例 看起来我缺少步骤,它是抱怨缺少步骤,并认为它们是未定义的 .功能文件:

  • 本文向大家介绍Jdbc的步骤以及简单实现代码,包括了Jdbc的步骤以及简单实现代码的使用技巧和注意事项,需要的朋友参考一下 创建一个以JDBC连接数据库的程序,包含7个步骤:   1、加载JDBC驱动程序:   在连接数据库之前,首先要加载想要连接的数据库的驱动到JVM(Java虚拟机),这通过java.lang.Class类的静态方法forName(String  className)实现。  

  • 我试着做了一个简单的测试来尝试黄瓜是如何与柏树一起工作的,但是我没有设法解决标题中描述的问题。 贝娄是我的js文件: 这是一个屏幕截图,其中包含问题输入图像描述 在尝试了很多事情,但我没有设法解决这个问题。有什么建议吗?

  • 本文向大家介绍基于JS实现bookstore静态页面的实例代码,包括了基于JS实现bookstore静态页面的实例代码的使用技巧和注意事项,需要的朋友参考一下 先给大家展示下效果图,如果感觉还不错,请参考实现代码: bookstore静态页面代码如下: 以上所述是小编给大家介绍的bookstore静态页面的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常

  • 问题内容: 我在下面编写了一些使用Promise的代码,而我找到它的最简单方法是使用对象而不是通常的Promise执行程序函数,因为我需要从执行程序外部解析Promise。我想知道是否存在基于Promise执行程序功能的可接受的设计模式,而不使用类似延迟的解决方案?无需从承诺执行者外部解决承诺就可以做到吗? 这是详细信息。 我有一个项目,该项目使用一组工作线程以及希望不时使用工作线程的代码的各个部