【发布时间】:2019-06-27 22:03:56
【问题描述】:
我将 Behat 用于 BDD 并使用 Scenario Outlines,因此我可以轻松地对其他数据进行相同的测试。但是我遇到了大文本的问题。请参见下面的示例:
Scenario Outline: create a thing
When I click on "New"
Then I should be at "/thing/new"
When I fill in "title" with <title>
When I fill in "description" with "description"
When I click on "save"
Then I should be at "/things"
Then I should see <title> in the list
When I click on <title>
Then I should see <title>
Then I should see <description>
Examples:
| title | description |
| "My new thing" | "a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string" |
您可以想象,如果有更多大文本或更多类型的值,这可能会很烦人。有解决方案吗?例如使用变量?可能是这样的:
$myvar = "a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string a very large string"
Scenario Outline: create a thing
When I click on "New"
Then I should be at "/thing/new"
When I fill in "title" with <title>
When I fill in "description" with "description"
When I click on "save"
Then I should be at "/things"
Then I should see <title> in the list
When I click on <title>
Then I should see <title>
Then I should see <description>
Examples:
| title | description |
| "My new thing" | $myvar |
【问题讨论】: