Sony
Sony

Reputation: 1793

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

I'm testing Behat/Mink for the first time with a simple example. When I launch behat I have this error :

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"')
        );
    }
}

Upvotes: 0

Views: 1057

Answers (1)

Jakub Zalas
Jakub Zalas

Reputation: 36241

In Behat2, Given/When/Then classes were used for step chaining. Since this technique brought more problems (with maintenance) then benefits, they're no longer supported in Behat3 (which you apparently use). It's also not recommended to follow this practice.

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

Upvotes: 2

Related Questions