guilhermeguitte / behat-laravel
此包已 弃用 且不再维护。未建议替代包。
将 Behat 测试添加到 laravel 4
v1.5
2014-08-06 12:03 UTC
Requires
- php: >=5.3.0
- alexandresalome/php-selenium: 1.0.1
- behat/behat: 2.5.*
- behat/mink-extension: 1.3.3
- illuminate/support: *
- zizaco/testcases-laravel: dev-master
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is auto-updated.
Last update: 2022-02-07 17:02:05 UTC
README
Behat-Laravel 是一个使用 BDD 方法测试应用解决方案。
特性
当前
- 创建接受测试的文件夹结构。
- 运行接受测试。
- 与 Zizaco/TestCases-Laravel 集成,该库提供了测试应用的有用方法。
快速入门
所需设置
在 composer.json
文件的 require
键中添加以下内容
"guilhermeguitte/behat-laravel": "dev-master"
运行 Composer 更新命令
$ composer update
在 config/app.php
文件中将 'GuilhermeGuitte\BehatLaravel\BehatLaravelServiceProvider'
添加到 $providers
数组的末尾
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'GuilhermeGuitte\BehatLaravel\BehatLaravelServiceProvider',
),
安装 selenium
。
http://docs.seleniumhq.org/download/
命令
现在使用以下 artisan 命令生成 Behat 的结构文件夹
$ php artisan behat:install
如果您不使用 app/tests
文件夹,可以传递测试路径。
$ php artisan behat:install --test_path==your/test/path
生成文档
要创建 HTML 文档,只需运行
$ php artisan behat:html # will create a file at application's root
或
$ php artisan behat:html --out path/you/need/doc.html # will create a file specified path
结构
添加上下文
当在 tests\acceptance\contexts
文件夹中创建 context
时,这些文件将由 FeatureContext
包含,防止指定将用于测试的文件。
$ php artisan behat:feature --name=NameOfFeature
将创建
app\tests\acceptance\contexts\NameOfFeatureContext.php
app\tests\acceptance\features\name_of_feature\name_of_feature.feature
运行测试
要运行所有测试,可以使用以下命令
$ php artisan behat:run
要运行特定功能的测试,可以指定文件夹名称或 .feature 文件名
$ php artisan behat:run name_of_feature
$ php artisan behat:run name_of_feature/name_of_feature.feature
$ php artisan behat:run name_of_feature/separated_scenarios.feature
如果您有大型功能文件并且只想运行特定场景,可以使用
$ php artisan behat:run --name="name of feature"
Laravel behat 当前支持以下 behat 命令行选项
--format (-f) How to format features. pretty is default.
Default formatters are:
- pretty: Prints the feature as is.
- progress: Prints one character per step.
- html: Generates a nice looking HTML report.
- junit: Generates a report similar to Ant+JUnit.
- failed: Prints list of failed scenarios.
- snippets: Prints only snippets for undefined steps.
--no-snippets Do not print out snippets
--profile (-p) Specify config profile to use.
--name Only execute the feature elements which match
part of the given name or regex.
许可
Behat-Laravel 是在 MIT 许可证下分发的免费软件。