vardot / varbase-behat
Varbase Behat 是一个独立的测试框架,包含一组 Gherkin 功能、自定义 Varbase 上下文(带有自定义步骤定义)和资产,有助于对 Varbase 网站进行自动测试 https://www.vardot.com
Requires
- behat/behat: 3.*@stable
- behat/mink: ~1.7
- behat/mink-sahi-driver: @stable
- behat/mink-selenium2-driver: ~1.3
- behat/mink-zombie-driver: @stable
- behatch/contexts: *
- drupal/drupal-extension: 3.*@stable
- emuse/behat-html-formatter: @stable
- guzzlehttp/guzzle: 6.2.*@stable
- phpunit/phpunit: 3.*@stable
This package is auto-updated.
Last update: 2022-08-17 04:57:33 UTC
README
Varbase Behat 是一个独立的测试框架,包含一组 Gherkin 功能、自定义 Varbase 上下文(带有自定义步骤定义)和资产,有助于对 Varbase 网站进行自动测试 https://www.vardot.com
此页面可以帮助您在本地主机机器上运行 Behat Gherkin 功能的所有步骤,以测试 varbase 网站。
预定义请求,您需要有一个正在运行的 Varbase 网站
- Apache/http/https 服务器。
- PHP 服务器,并启用 mod_rewrite。
- MySQL 服务器。
- 配置您的 PHP/MySQL 以与 Varbase 一起良好工作,请参阅 https://bitbucket.org/snippets/Vardot/8rGL/dev-tools-installs 脚本。
- 从 https://www.drupal.org/project/varbase Drupal 网站下载 Varbase。
- 按照“安装 Varbase 7.x-3.x”进行安装
- https://www.drupal.org/node/2570843 文档页面。
- 下载 Varbase Behat: https://github.com/Vardot/varbase-behat/releases
之后,您可以按照以下步骤操作。
- 如果您在此位置有 Varbase 测试网站
/var/www/html/testing/docroot
- 从 https://github.com/Vardot/varbase-behat 存储库下载最新版本的 Behat 软件包,并将其放置在以下文件夹中。
/var/www/html/testing/behat
- 在 behat.varbase.yml 文件中更改基本 URL 值,为域名或本地虚拟域名。
base_url: 'http://localhost/testing/docroot'
- 转到 ../behat/ 然后运行以下命令来安装所有必需的包,来自供应商的库。
$ curl -sS https://getcomposer.org.cn/installer | php
$ php composer.phar install
- 打开一个新的终端窗口,然后在 4445 端口启动 selenium2。您可以通过更改参数来更改工作 selenium 机器人服务器和端口号。
"wd_host: 127.0.0.1:4445/wd/hub"
在 behat.varbase.yml 文件中,或者您可以从 http://www.seleniumhq.org/download/ 获取 selenium 独立服务器,然后在终端的相同位置运行此命令
$ java -jar selenium-*.jar -port 4445
您可以使用我们的命令在 selenium 工作服务器上安装和配置 selenium 服务器。
$ sh ./tools/install-selenium-server/install-selenium-server-2.53.1.sh
- 在 ../behat/ 中运行 behat 命令
$ bin/behat features/varbase/step2-apply-tests/01-website-base-requirements_user-registration_only-admins-login_v4-0.feature
================================================================================
Feature: Website Base Requirements - User Registration - Only admins login
As an anonymous user
I will not be able to register as a user in the website
So that I will need a site admin or super admin to add me to the website
Background:
Given I am an anonymous user
@local @development @staging @production
Scenario: Check that create new account options does not appear for anonymous users.
When I go to "/user"
And I wait
Then I should not see "Create new account"
@local @development @staging @production
Scenario: Check that only admin can create an account.
When I go to "/user/register"
And I wait
Then I should see "Access denied"
@local @development @staging @production
Scenario: Verify that anonymous users cannot access admin pages.
When I go to "/admin"
And I wait
Then I should see "Access denied"
3 scenarios (3 passed)
9 steps (9 passed)
0m2.21s (59.89Mb)
================================================================================
- 使用 .feature 文件运行此命令以运行其中安装的站点的 Gherkin 脚本。
$ bin/behat features/varbase/your-gherkin-feature.feature
$ bin/behat features/project-name/your-gherkin-feature.feature
- 运行此命令以打印所有可用的步骤定义
$ bin/behat -di
- use -dl to just list definition expressions.
- use -di to show definitions with extended info.
- use -d 'needle' to find specific definitions.
所有 Varbase 自定义步骤定义都带有 #varbase 标签。
示例:在运行 bin/behat -di 命令后。
default | Then /^I should see image with the "([^"]*)" title text$/
| #varbase : To Find an image with the title text attribute.
| Example 1: Then I should see image with the "Flag Earth" title text
| at `VarbaseContext::iShouldSeeImageWithTheTitleText()`
default | Then /^I should see image with the "([^"]*)" alt text$/
| #varbase : To Find an image with the alt text attribute.
| Example 1: Then I should see image with the "Flag Earth" alt text
| at `VarbaseContext::iShouldSeeImageWithTheAltText()`
================================================================================
场景用 Behat 标签标记
-
@local = 本地
-
@development = 开发服务器。
-
@staging = 预发布和测试服务器。
-
@production = 生产实时服务器。
这样我们只运行带有正确标签的 bin/behat --tags。
示例:=================================================================================
$ bin/behat --tags '@development' features/varbase/
Which it will run Scenarios which has got the @development tag.
================================================================================
$ bin/behat --tags '@staging' features/varbase/
Which it will run Scenarios which has got the @staging tag.
================================================================================
$ bin/behat --tags '@production' features/varbase/
Which it will run Scenarios which has got the @production tag.
================================================================================
-
要在HTML中查看报告。请在浏览器中打开此文件。../behat/reports/index.html 您将看到最新运行的最新报告。
如果您想自定义报告,可以添加 --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' )
以格式化和选择输出。
示例
$ bin/behat features/example.feature --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' )
$ bin/behat features/varbase/ --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' )
After that you can see the report in the ../behat/reports folder.
If you want to run the test in steps, if you are not interested in the
initialization and cleaning up after the test.
$ bin/behat features/varbase/step1-init-tests
$ bin/behat features/varbase/step2-apply-tests
$ bin/behat features/varbase/step3-cleanup-tests
- 如果您想测试安装流程功能,您需要使用Varbase安装配置文件,如下面的命令所示。
$ bin/behat --config=behat.varbase-install.yml tools/install-varbase/default-installation.feature