Sam*_*mer 7 php autoload behat composer-php
我过去曾尝试过 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": "*"
}
Run Code Online (Sandbox Code Playgroud)
}
我的项目文件夹的结构如下:
behat/
bootstrap/
FeatureContext.php
config/
behat.yml
features/
CheckHome.feature
vendor/
composer.json
composer.lock
Run Code Online (Sandbox Code Playgroud)
还有我的 behat.yml 文件:
default:
autoload:
'': %paths.base%/../bootstrap
suites:
default:
paths:
- %paths.base%/../features
contexts:
- FeatureContext
Run Code Online (Sandbox Code Playgroud)
当我尝试使用 CheckHome.feature 运行场景时
vendor/bin/behat
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Behat\Behat\Context\Exception\ContextNotFoundException]
`FeatureContext` context class not found and can not be used.
Run Code Online (Sandbox Code Playgroud)
设置自动加载以便识别我的上下文的正确方法是什么?
谢谢
我修好了它。我假设基本路径是我的目录的根目录,但它是存储 behat.yml 的地方。因此,为了使用我当前的配置,我必须按如下方式更改 behat.yml 文件中的路径:
default:
autoload:
'': %paths.base%/../bootstrap
suites:
default:
paths:
- %paths.base%/../features
contexts:
- FeatureContext
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10692 次 |
| 最近记录: |