我试图使断言随机文本在一个字段中输入出现下一个页面(确认)贝哈特从测试步骤
上传递一个值我不喜欢这样
When I fill in "edit-title" with random value of length "8"
/**
* Fills in form field with specified id|name|label|value with random string
* Example: And I fill in "bwayne" with random value of length "length"
*
* @When /^(?:|I)fill in "(?P<field>(?:[^"]|\\")*)" with random value of length "(?P<length>(?:[^"]|\\")*)"$/
*/
public function fillFieldWithRandomValue($field, $length)
{
$field = $this->fixStepArgument($field);
$value = $this->generateRandomString($length);
$this->getSession()->getPage()->fillField($field, $value);
}
比我想作出断言 - 如下所示:
Then I should see text matching "<RANDOM VALUE ENTERED IN THE PREVIOUS STEP>"
是否有可能?
UPDATE:
但如何将它看起来像getter和setter方法,如果我想使用一个generateRandomString方法多次,然后得到这个方法的值此起彼伏?我必须为每个测试步骤制作变量和函数吗?像这样:
When I fill in "x" with random value of length "8"
And I fill in "y" with random value of length "12"
And I go to other page
Then I should see text matching "VALUE ENTERED TO X"
And I should see text matching "VALUE ENTERED TO Y"