gpt4 book ai didi

php - Behat 3 - `FeatureContext` 上下文类未找到且无法使用

转载 作者:可可西里 更新时间:2023-10-31 22:42:58 26 4
gpt4 key购买 nike

我过去曾尝试过 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

关于php - Behat 3 - `FeatureContext` 上下文类未找到且无法使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26658511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com