xendk / proctor
Drupal网站测试助手。
Requires
- php: >=5.4.0
- symfony/console: ~2.4
- symfony/finder: ~2.6
- symfony/process: ~2.0
- symfony/yaml: ~2.4
Requires (Dev)
- behat/behat: ~3.0
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2022-04-14 00:30:18 UTC
README
帮助测试Drupal网站。
使用Behat、Selenium、Codeception或其他“基于浏览器”的方法测试Drupal网站,涉及大量的设置和配置,包括本地和CI服务器上。Proctor试图尽可能自动化。
操作流程
在Drupal根目录的tests
文件夹中安装Proctor及其依赖项
composer require xendk/proctor:~0.1
在测试文件夹中使用composer文件的原因是它将测试工具保留在Drupal依赖之外。Drupal 8 beta 10和CodeCeption 2.*依赖于不兼容的PHPUnit版本,随着Drupal包含更多库,未来的冲突是不可想象的。
提交tests/composer.json
和tests/composer.lock
文件。
运行
./tests/vendor/bin/proctor config:init
初始化一个~/.proctor.yml
配置文件。编辑该文件并提供本地环境的mysql凭证。这允许Proctor创建测试网站。
运行
./tests/vendor/bin/proctor setup:drupal @alias
其中@alias
是从该别名同步数据库和文件的Drush别名。这可以是生产网站、预发布网站或仅用于测试的网站。
运行
./tests/vendor/bin/proctor build test.mysite.dev
这将创建一个新的test.mysite.dev
网站在sites/
中,将其添加到sites/sites.php
中,同步数据库和文件,并在网站上清除缓存。现在您有一个新的测试网站。重新运行该命令将用新的副本覆盖网站。
现在您可以为测试添加测试。您可以将Behat测试放在tests/behat/
中,将Codeception测试放在tests/codecept
中,Proctor将运行适当的工具(可能还会出现其他测试框架)。
运行
./tests/vendor/bin/proctor use test.mysite.dev
这将修复Behat/Codeception YAML配置文件,使其指向正在测试的主机名。要标记URL进行修复,请在行尾添加# proctor:host
。
运行
./tests/vendor/bin/proctor prepare
启动Selenium服务器。您可以在~/.proctor.yml
中配置Selenium服务器JAR文件的路径,或者添加--fetch开关以下载它。
运行
./tests/vendor/bin/proctor run
在本地运行所有测试。
CircleCI
Proctor了解Circle CI,因此要在这里运行测试,您需要一个类似于以下内容的circle.yml文件
machine: environment: # Add composer global bin dir to path, needed to find drush. PATH: $HOME/.composer/vendor/bin:$PATH php: # Currently Proctor needs to have the PHP version specified in here. version: 5.4.21 dependencies: override: # Install Proctor and dependencies. - composer install --no-interaction: pwd: tests # Install Drush - composer --prefer-source --no-interaction global require drush/drush:6.2.0 # This will make sending mail from PHP not fail. - echo "sendmail_path = /bin/true" > ~/.phpenv/versions/$(phpenv global)/etc/conf.d/sendmail.ini cache_directories: - "~/.composer" # Cache the Selenium Server JAR file here. - "~/aux" post: # Prepare Apache virtual host. - ./tests/vendor/bin/proctor setup:circle # Start Selenium Server in the background. - ./tests/vendor/bin/proctor prepare --fetch --selenium-dir ~/aux: background: true # Temporary hack. This ensures that the Drush command that Proctor uses # for syncing doesn't get the message from SSH about a new host. It # messes things up. - ssh drush-user@hostname echo "test" # Build site. - ./tests/vendor/bin/proctor build default # And fix Behat/Codeception files to point at it. - ./tests/vendor/bin/proctor use localhost:8080 test: override: # Run the tests. - ./tests/vendor/bin/proctor run