我是Cucumber的新手,在运行特定的黄瓜情景时遇到了奇怪的问题。 以下是我在功能文件中定义的两个场景。 第一个场景没有任何问题,但黄瓜在运行测试用例时甚至没有考虑第二个。
Scenario Outline:
1.Validate create functionality
Given user is on "Home" screen
When click on Create
Then create screen should render
Scenario Outline:
2.Validate create Name,Description,Start Date
Given user is on create screen
When user enters following values:
| Name | dummyName |
| Desc | dummyDesc@# |
| Date | ghgh |
Then there should be error message on the screen.
以下是java中的功能实现方法
情景1。
@Given("^user is on \"([^\"]*)\" screen$")
public void homeScreen(String home) throws Throwable {
//someCode
}
@When("^click on Create$")
public clickCreate() throws Throwable {
//someCode
}
@Then ("^create screen should render$")
public void createRender() throws Throwable {
//someCode
}
情景2。
@Given("^user is on create screen$")
public void crateScreen() throws Throwable {
//someCode
}
@When("^user enters following values :$")
public void EnterValues(Map<String,String> map) throws Throwable {
//someCode
}
@Then("^there should be error message on the screen.$")
public void errorMessage() throws Throwable {
//someCode
}
为什么Cucumber不调用Scenario?
环境 - 黄瓜,硒,JAVA
答案 0 :(得分:1)
因为你没有在示例表中使用变量名周围的任何占位符。事实上,我在你的代码中看到了许多小黄瓜语法问题。试试这个:
Scenario Outline: Validate Input Fields
Given user is on create screen
When user enters following values <createName>,<Description>,<StartDate>
Then should receive this <ErrorMessage>
Examples:
| createName| Description| StartDate| ErrorMessage|
| DummyName| dummyDesc@#| ghgh| Invalid Date Entered |