Behat 为水貂创建步骤
我是水貂、贝哈特等的新手,所以我需要帮助 我有一个包含一些行的表,我想检查是否删除了一行 在我的场景中,我有如下内容:Behat 为水貂创建步骤,behat,mink,Behat,Mink,我是水貂、贝哈特等的新手,所以我需要帮助 我有一个包含一些行的表,我想检查是否删除了一行 在我的场景中,我有如下内容: 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" 我是怎么做到的?如何“响应不应包含一行的
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"
我是怎么做到的?如何“响应不应包含一行的某些值”
我不知道这是否适用于水貂,或者我需要使用单一测试。您可以在步骤中使用:
And the result table should not contain:
|Value |
|Value1|
|Value2|
|Value3|
|Value4|
Behat将其作为TableNode实例传递给步骤方法:
/**
* @Given /the result table should not contain:/
*/
public function thePeopleExist(TableNode $table)
{
$hash = $table->getHash();
foreach ($hash as $row) {
// ...
}
}
/**
* @Given /^I should see a list of users$/
*/
public function iShouldSeeListOfUsers()
{
return new Then('I should see "User list"');
}
阅读更多关于用小黄瓜语言编写功能的信息:
离题:请注意,大多数情况下,在功能中直接使用貂皮步骤并不是最好的主意,因为大多数情况下,貂皮步骤不是您的业务语言。如果您编写了以下内容,您的场景将更具可读性和可维护性:
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 |
在步骤实现中,可以通过返回以下实例来使用默认的Mink步骤:
/**
* @Given /the result table should not contain:/
*/
public function thePeopleExist(TableNode $table)
{
$hash = $table->getHash();
foreach ($hash as $row) {
// ...
}
}
/**
* @Given /^I should see a list of users$/
*/
public function iShouldSeeListOfUsers()
{
return new Then('I should see "User list"');
}
我删除了
Symfony
标记,因为它没有太多要处理的内容