【发布时间】:2018-08-07 21:23:02
【问题描述】:
我正在使用 Scala、Cucumber、Gherkin 语言进行自动化测试。我的功能文件中有以下场景,用 Gherkin 语言编写:
Scenario Outline: Do something
When I do something
Then result should have field1 as "<filed_1>", field2 as "<filed_2>" and filed3 as "<filed_3>"
而生成的stepdef是:
When("""^I do something$""") {
// do operation
}
Then("""^result should haveresult should have field1 as "([^"]*)",
field2 as "([^"]*)" and filed3 as "([^"]*)"$""") {
// do operation
}
这里 Then 语句在一行中有超过 120 个字符,我必须将其分成两部分。我不应该更改功能文件。
当把那么分成两行
Then("""^result should haveresult should have field1 as "([^"]*)",
| field2 as "([^"]*)" and filed3 as "([^"]*)"$""".stripMargin)
它说您可以使用下面的 sn-ps 实现缺少的步骤:
Then("""^result should have field1 as "([^"]*)", field2 as "([^"]*)" and filed3 as "([^"]*)"$"""){ (arg0:String, arg1:String, arg2:String) =>
//// Write code here that turns the phrase above into concrete actions
throw new PendingException()
}
我不确定应该采用哪种方法将 然后 分成多行。感谢任何帮助。
【问题讨论】: