我的测试用例包含一些重复步骤
Given user 123456 with amount USD50
When charge request made by User
Then Charge request should be success
When refund request made by user for USD50
Then Refund request should be success
When refund request made by user for USD50
Then Refund request should be fail
我希望使用http://jbehave.org/reference/stable/parametrised-scenarios.html中解释的表格参数。
但是我没有将测试分成两个场景,而是将其保持为一个场景
最后它应该类似于下面的内容。 例如:
Given user <user> with amount <charge>
When charge request made by the user
Then Charge request should be success
When refund request made by user for <refund>
Then Refund request should be <result>
When refund request made by user for <refund>
Then Refund request should be <result>
Examples:
|user|charge|refund|result|refund|result|
|123456|USD50|USD50|success|USD50|fail|
|123456|USD50|USD20|success|USD10|fail|
但执行结果页面时,参数表显示为
user charge refund result refund result
postpaid USD50 USD50 fail USD50 fail
postpaid USD50 USD10 fail USD10 fail
似乎字段被分配到最后一个值。
我无法用两个不同的名称命名文件(例如:refund1,refund2),因为该方法是使用命名参数编写的
@When("refund request made by user for $refund)
@Alias("refund request made by user for <refund>")
public void refundRequest(@Named("refund") String refund){
//refund code
}
请帮助
答案 0 :(得分:2)
为了实现这一点,您需要更改参数控件以使用分隔符命名参数,如下所示:
public ParametrisationByDelimitedName() {
useConfiguration(new MostUsefulConfiguration()
.useParameterControls(new ParameterControls().useDelimiterNamedParameters(true))
.useStoryReporterBuilder(
new StoryReporterBuilder().withFormats(Format.CONSOLE)));
}
有关完整示例,请参阅以下链接: