我第一次用一个简单的例子测试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/Whin/Then类用于步骤链接。由于这项技术带来了更多的问题(维护),然后带来了好处,因此Behat3中不再支持这些问题。也不建议遵循此做法。
请参阅https://github.com/Behat/Behat/issues/546.