xendk/proctor

此包已被废弃,不再维护。未建议替代包。

Drupal网站测试助手。

1.0.1 2015-04-25 09:40 UTC

This package is auto-updated.

Last update: 2022-04-14 00:30:18 UTC


README

Circle CI Travis CI Scrutinizer Code Quality

帮助测试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.jsontests/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