我正在使用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>]
我尝试过移动,删除自定义目录,套件等等 - 没有任何作用。
如何识别功能文件?
答案 0 :(得分:3)
结果证明答案要简单得多。
请注意behat.yml
:
filters:
tags: web
由于相应的上下文没有此标记,因此该功能无法执行。我暂时删除了tags
- 现在正在运行该功能。
答案 1 :(得分:0)
请再次检查您的路径 - 在您的情况下,它应该类似于:
default:
suites:
web:
paths: [ %paths.base%/test/features/web ]
将behat.yml
文件移动到项目根目录。我认为现在正在调用bin/behat
对behat.yml
文件一无所知。
我假设您从bin/behat
路径运行project/
。
这与:http://docs.behat.org/en/v3.0/user_guide/configuration.html#custom-autoloading
有关