【问题标题】:Behat 3 - Behat\Behat\Context\Step\Given not foundBehat 3 - Behat\Behat\Context\Step\Given 未找到
【发布时间】:2015-03-06 00:17:03
【问题描述】:

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

【问题讨论】:

    标签: php bdd behat mink


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多