在有效特征文件的路径中未找到规范
No specifications found at path for a valid feature file
我正在使用 behat 设置自动化测试(注意:我正在使用 behat 3)。我有以下目录结构:
project/
test/
features/
web/
login.feature
bootstrap/
Web/
LoginContext.php
behat.yml
这是整个方法的初步测试。我明确表示要保持简单。
我的 behat.yml
包含以下内容(仅此而已 - 其他内容稍后会出现)。
default:
suites:
web:
paths: [%paths.base%/features/web]
contexts: [Web\LoginContext]
我唯一的功能文件包含以下内容:
Feature: Login to MedNav
In order to use MedNav application
As a user
I need to be able to login
Scenario: Valid login credentials
Given I am on the login page
When I enter invalid credentials
And I hit log in button
Then I should see "Loading, please wait..."
And I should navigate to Emergency List page
在我执行 behat --init
之后,它创建了文件 Web\LoginContext
,我在其中添加了步骤的存根。
然而,当我尝试执行它时,没有任何反应:
$ bin/behat
No scenarios
No steps
0m0.01s (13.16Mb)
如果我指定要执行的功能,它会告诉我 No specifications found at path(s) 'features/web/login.feature'
$ bin/behat features/web/login.feature
No scenarios
No steps
0m0.01s (13.16Mb)
[Behat\Testwork\Tester\Exception\WrongPathsException]
No specifications found at path(s) `features/web/login.feature`.
behat [-s|--suite SUITE] [-f|--format FORMAT] [-o|--out OUT] [--format-settings FORMAT-SETTINGS] [--init] [--lang LANG] [--name NAME] [--tags TAGS] [--role ROLE] [--story-syntax] [-d|--definitions DEFINITIONS] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--dry-run] [--] [<paths>]
我试过四处移动,删除自定义目录、套件等 - 没有任何效果。
如何让 behat 识别功能文件?
请再次检查您的路径 - 在您的情况下,它应该类似于:
default:
suites:
web:
paths: [ %paths.base%/test/features/web ]
并将behat.yml
文件移动到项目根目录。我认为现在调用 bin/behat
Behat 对 behat.yml
文件一无所知。
我假设你是 运行 bin/behat
来自 project/
路径。
这与:http://docs.behat.org/en/v3.0/user_guide/configuration.html#custom-autoloading
相关
原来答案简单多了。
在 behat.yml
中注意这一点:
filters:
tags: web
因为相应的上下文没有这个标签,所以功能没有执行。我暂时删除了 tags
- 现在的功能是 运行.
我正在使用 behat 设置自动化测试(注意:我正在使用 behat 3)。我有以下目录结构:
project/
test/
features/
web/
login.feature
bootstrap/
Web/
LoginContext.php
behat.yml
这是整个方法的初步测试。我明确表示要保持简单。
我的 behat.yml
包含以下内容(仅此而已 - 其他内容稍后会出现)。
default:
suites:
web:
paths: [%paths.base%/features/web]
contexts: [Web\LoginContext]
我唯一的功能文件包含以下内容:
Feature: Login to MedNav
In order to use MedNav application
As a user
I need to be able to login
Scenario: Valid login credentials
Given I am on the login page
When I enter invalid credentials
And I hit log in button
Then I should see "Loading, please wait..."
And I should navigate to Emergency List page
在我执行 behat --init
之后,它创建了文件 Web\LoginContext
,我在其中添加了步骤的存根。
然而,当我尝试执行它时,没有任何反应:
$ bin/behat
No scenarios
No steps
0m0.01s (13.16Mb)
如果我指定要执行的功能,它会告诉我 No specifications found at path(s) 'features/web/login.feature'
$ bin/behat features/web/login.feature
No scenarios
No steps
0m0.01s (13.16Mb)
[Behat\Testwork\Tester\Exception\WrongPathsException]
No specifications found at path(s) `features/web/login.feature`.
behat [-s|--suite SUITE] [-f|--format FORMAT] [-o|--out OUT] [--format-settings FORMAT-SETTINGS] [--init] [--lang LANG] [--name NAME] [--tags TAGS] [--role ROLE] [--story-syntax] [-d|--definitions DEFINITIONS] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--dry-run] [--] [<paths>]
我试过四处移动,删除自定义目录、套件等 - 没有任何效果。
如何让 behat 识别功能文件?
请再次检查您的路径 - 在您的情况下,它应该类似于:
default:
suites:
web:
paths: [ %paths.base%/test/features/web ]
并将behat.yml
文件移动到项目根目录。我认为现在调用 bin/behat
Behat 对 behat.yml
文件一无所知。
我假设你是 运行 bin/behat
来自 project/
路径。
这与:http://docs.behat.org/en/v3.0/user_guide/configuration.html#custom-autoloading
相关原来答案简单多了。
在 behat.yml
中注意这一点:
filters:
tags: web
因为相应的上下文没有这个标签,所以功能没有执行。我暂时删除了 tags
- 现在的功能是 运行.