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 许可证下免费分发的软件。