Java - 黄瓜示例
看起来我缺少步骤,它抱怨缺少步骤并将它们视为未定义
.feature 文件:
Feature: Roman Feature
Scenario: Convert Integer to Roman Number
Given I am on the demo page
When I pass number 1
Then the roman result is I
Scenario: Convert Integer to Roman Number
Given I am on the demo page
When I pass number 5
Then the roman result is V
步骤文件:
@When("^I pass number (\\d+)$")
public void convert_numbers_to_roman(int arg1) throws Throwable {
// convert number
}
@Then("^the roman result is (\\d+)$")
public void the_roman_result_is(int result) throws Throwable {
// match result
}
当我运行测试
Scenario: Convert Integer to Roman Number [90m# net/xeric/demos/roman.feature:3[0m
[32mGiven [0m[32mI am on the demo page[0m [90m# DemoSteps.i_am_on_the_demo_page()[0m
[32mWhen [0m[32mI pass number [0m[32m[1m1[0m [90m# DemoSteps.convert_numbers_to_roman(int)[0m
[33mThen [0m[33mthe roman result is I[0m
6 场景 2 未定义 您可以使用以下代码片段实现缺少的步骤:
@Then("^the roman result is I$")
public void the_roman_result_is_I() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}