我对Mink,Behat等很不熟悉,所以我需要帮助。
我有一个包含一些行的表,我想检查是否有一行被删除。
在我的场景中,我有这样的东西:
When I press "Delete"
Then I should be on "/example_url/"
And I should see "Object list"
And the response should not contain "Value1" "Value2" "Value3" "Value4"我该怎么做呢?我怎么做“响应不应该包含一行的一些值”?
我不知道这是否可能与Mink或我需要使用单位测试。
发布于 2012-08-06 23:30:30
您可以在步骤中使用tables:
And the result table should not contain:
|Value |
|Value1|
|Value2|
|Value3|
|Value4|Behat会将其作为TableNode实例传递给您的step方法:
/**
* @Given /the result table should not contain:/
*/
public function thePeopleExist(TableNode $table)
{
$hash = $table->getHash();
foreach ($hash as $row) {
// ...
}
}阅读更多关于用小黄瓜语言编写特性的文章:http://docs.behat.org/guides/1.gherkin.html
Mink Digression:请注意,大多数时候在你的特性中直接使用Mink步骤并不是最好的主意,因为大多数时候它不是你的业务语言。如果您编写了以下代码,您的场景将更具可读性和可维护性:
When I press "Delete"
Then I should be on the user page
And I should see a list of users
And the following users should be deleted:
|Name |
|Biruwon|
|Kuba |
|Anna |在步骤实现中,您可以通过返回Then instance来使用默认的Mink步骤:
/**
* @Given /^I should see a list of users$/
*/
public function iShouldSeeListOfUsers()
{
return new Then('I should see "User list"');
}https://stackoverflow.com/questions/11830072
复制相似问题