Behat 3 - Behat \ Behat \ Context \ Step \鉴于未找到

时间:2015-03-05 12:34:24

标签: php bdd behat mink

我是第一次用一个简单的例子测试Behat / Mink。 当我启动behat时出现此错误:

PHP Fatal error: Class 'Behat\Behat\Context\Step\Given' not found in /var/www/behat-test/features/bootstrap/FeatureContext.php on line 31

features / bootstrap / FeatureContext.php:

<?php
require_once './vendor/autoload.php';

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Behat\Context\Step;

class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
{
    // ......

    /**
     * @Given I am logged in as :username
     */
    public function iAmLoggedInAs($username)
    {
        return array(
            new Step\Given('I go to "login.php"'), // line 31
            new Step\When('I fill in "My name" with '.$username),
            new Step\When('I press "Login"')
        );
    }
}

1 个答案:

答案 0 :(得分:2)

在Behat2中, Given / When / Then 类用于步骤链接。由于这种技术带来了更多问题(有维护)然后带来好处,因此Behat3 (您显然使用它)不再支持。也不建议遵循这种做法。

请参阅https://github.com/Behat/Behat/issues/546