Behat 3 - Behat\Behat\Context\Step\Given 未找到

Behat 3 - Behat\Behat\Context\Step\Given not found

我第一次用一个简单的例子测试 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"')
        );
    }
}

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

https://github.com/Behat/Behat/issues/546