我用serenitybdd和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**
尽管我已经实现了这些方法,我还是得到了这个。我的跑步者,黄瓜步和特征文件如下。
跑:
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/", glue = "cucumbersteps")
public class EbebekRunner {
}
cucumbersteps:
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 |
我的项目结构如下所述。
输入图片描述
我试过把胶水换成{"黄瓜步"},但什么也没变。我不明白为什么问题是调用。有人能帮我吗?
老实说,这种类型的错误是棘手的,它可能发生的原因有多种(例如,有运行器,步骤或功能外的测试文件夹),然而,基于您共享的信息,尝试添加功能文件的名称在路径:
@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")