我正在做一个 Symfony 项目,我想用 Behat/Mink 创建单元测试。
我有一个场景:
Feature: Homepage
Scenario: Check if I can log on
Given I am on "/"
And I follow "connexion_js"
And I switch to the iframe "cboxIframe"
我已经在 FeatureContext 类中定义了最后一行。
class FeatureContext extends MinkContext implements KernelAwareInterface{
// ...
/**
* @Given /^I switch to the iframe "([^"]*)"$/
*/
public function iSwitchToIframe($arg1 = null)
{
$this->getSession()->switchToIFrame($arg1);
}
}
当我执行我的 shell 命令时:
$: bin/behat "@PoleMainBundle"
Feature: Homepage
Scenario: Check if I can log on # src/xxx/xxx/MainBundle/Features/homepage.feature:2
Given I am on "/" # xxx\xxx\MainBundle\Features\Context\FeatureContext::visit()
And I follow "connexion_js" # xxx\xxx\MainBundle\Features\Context\FeatureContext::clickLink()
And I switch to the iframe "cboxIframe" # xxx\xxx\MainBundle\Features\Context\FeatureContext::iSwithToIframe()
iFrame management is not supported by Behat\Symfony2Extension\Driver\KernelDriver
...