java - Cucumber+Serenity “您可以使用下面的代码片段实现缺少的步骤”
问题描述
我开发了一个带有 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 {
}
黄瓜步骤:
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 |
我的项目结构如下所述。
我试图将胶水更改为 {"cucumbersteps"} 但没有任何改变。我不明白为什么会调用问题。谁能帮我?
解决方案
老实说,这种类型的错误很棘手,并且可能由于多种原因而发生(例如,将运行器、步骤或功能放在测试文件夹之外),但是,根据您共享的信息,尝试在其中添加功能文件的名称路径:
@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")
推荐阅读
- python - 如何使线程与 pynput 一起用于转义序列?
- python - 从峰值位置创建值窗口
- jenkins-pipeline - 你怎么知道路径是詹金斯管道中的文件还是目录
- javascript - 如何在不使用打包管理器的情况下将 localForage 添加到我的 Web 应用程序
- python - 如何将 keras 顺序模型恢复到之前构建的状态?
- java - 如何使用 Thymeleaf 读取 HTML 中的列表
- objective-c - NSTableView 删除表格视图边框和单元格之间的填充/空格
- python - 我应该在 Pycharm 中使用什么文件夹?
- reactjs - Microsoft Graph Toolkit - 如何使用 React 和默认模板循环获取组件结果
- c - 迭代中的Qsort?