I am trying to learn Behat using the tutorial on the website.
The first step goes OK, no errors appear.
But when I am changing the ls_project/features/bootstrap/FeatureContext.php
, as shown in the tutorial second step, I am getting the following error: 'Behat\Behat\Context\BehatContext' not found
.
The tutorial code, to which the change is applied:
# features/bootstrap/FeatureContext.php
<?php
use Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
class FeatureContext extends BehatContext
{
/**
* @Given /^I am in a directory "([^"]*)"$/
*/
public function iAmInADirectory($dir)
{
if (!file_exists($dir)) {
mkdir($dir);
}
chdir($dir);
}
}
The full error log:
11:51:33 / ME : /var/www/test-driven/behat/ls_project
$ behat
# features/bootstrap/FeatureContext.php
PHP Fatal error: Class 'Behat\Behat\Context\BehatContext' not found in /var/www/test-driven/behat/ls_project/features/bootstrap/FeatureContext.php on line 10
PHP Stack trace:
PHP 1. {main}() /opt/Behat/bin/behat:0
PHP 2. Symfony\Component\Console\Application->run() /opt/Behat/bin/behat:31
PHP 3. Behat\Testwork\Cli\Application->doRun() /opt/Behat/vendor/symfony/console/Symfony/Component/Console/Application.php:121
PHP 4. Symfony\Component\Console\Application->doRun() /opt/Behat/src/Behat/Testwork/Cli/Application.php:90
PHP 5. Symfony\Component\Console\Application->doRunCommand() /opt/Behat/vendor/symfony/console/Symfony/Component/Console/Application.php:191
PHP 6. Symfony\Component\Console\Command\Command->run() /opt/Behat/vendor/symfony/console/Symfony/Component/Console/Application.php:892
PHP 7. Behat\Testwork\Cli\Command->execute() /opt/Behat/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:241
PHP 8. Behat\Testwork\Tester\Cli\ExerciseController->execute() /opt/Behat/src/Behat/Testwork/Cli/Command.php:63
PHP 9. Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications() /opt/Behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:106
PHP 10. Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test() /opt/Behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:137
PHP 11. Behat\Testwork\Tester\Runtime\RuntimeExercise->test() /opt/Behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php:65
PHP 12. Behat\Testwork\Environment\EnvironmentManager->buildEnvironment() /opt/Behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php:67
PHP 13. Behat\Behat\Context\Environment\Handler\ContextEnvironmentHandler->buildEnvironment() /opt/Behat/src/Behat/Testwork/Environment/EnvironmentManager.php:69
PHP 14. Behat\Behat\Context\Environment\UninitializedContextEnvironment->registerContextClass() /opt/Behat/src/Behat/Behat/Context/Environment/Handler/ContextEnvironmentHandler.php:75
Could anyone please help me resolving this issue?