我过去曾经尝试过Behat 2.5,但没有问题进行设置,但是现在我刚刚下载了Behat 3,但在设置过程中遇到了一些困难。
我的问题是,在全新安装之后,如果我创建behat.yml文件,则似乎无法定义FeatureContext文件的位置,并且无法运行任何测试。
我的composer.json如下所示:
{
"require-dev": {
"behat/behat": "~3.0.4",
"sensiolabs/behat-page-object-extension": "2.0.*@dev"
},
"require": {
"behat/mink": "1.6.*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
}
}
我的项目文件夹的结构如下:
behat/
bootstrap/
FeatureContext.php
config/
behat.yml
features/
CheckHome.feature
vendor/
composer.json
composer.lock
和我的behat.yml文件:
default:
autoload:
'': %paths.base%/../bootstrap
suites:
default:
paths:
- %paths.base%/../features
contexts:
- FeatureContext
当我尝试使用以下方法运行CheckHome.feature中的方案时
vendor/bin/behat
我收到以下错误:
Behat\Behat\Context\Exception\ContextNotFoundException]
`FeatureContext` context class not found and can not be used.
设置自动加载以使其能够识别我的上下文的正确方法是哪种?
谢谢
我修好了它。我以为基本路径是目录的根目录,但是它是存储behat.yml的地方。因此,为了使用当前配置,我必须按如下所示更改behat.yml文件中的路径:
default:
autoload:
'': %paths.base%/../bootstrap
suites:
default:
paths:
- %paths.base%/../features
contexts:
- FeatureContext
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句