adamquaile/behat-command-runner-extension

该包的最新版本(v0.1.1)没有可用的许可证信息。

在测试生命周期钩子中运行命令的扩展

v0.1.1 2014-10-02 13:09 UTC

This package is auto-updated.

Last update: 2024-09-09 22:19:05 UTC


README

这是一个概念验证 - 请谨慎使用!

在测试生命周期钩子中运行命令的扩展,适用于缓存清理、数据库设置、拆解等...

安装

通过composer需要包 adamquaile/behat-command-runner-extension

composer require --dev "adamquaile/behat-command-runner-extension *@dev"

将配置添加到您的 behat.yml。以下示例显示了完整的配置选项。

default:
    extensions:
        AdamQuaile\Behat\CommandRunnerExtension:
              beforeSuite:
                  - echo "beforeSuite"
                  - { command: 'ping example.com', background: true }
              afterSuite:
                  - echo "afterSuite"
              beforeFeature:
                  - echo "beforeFeature"
                  - { command: 'ping example.com', background: true }
              afterFeature:
                  - echo "afterFeature"
              beforeScenario:
                  - echo "beforeScenario"
                  - { command: 'ping example.com', background: true }
              afterScenario:
                  - echo "afterScenario"

symfony2 示例

此示例运行 phantomjs 对我们的javascript behat测试进行操作,并为每个功能创建和重建测试数据库。

为了提高速度,数据库在设置阶段第一次运行后复制回原位,而不是每次都使用doctrine。

为了获得更多隔离,您可以在 beforeScenario 而不是 beforeFeature 上进行此复制。

default:
    extensions:
        AdamQuaile\Behat\CommandRunnerExtension:
              beforeSuite:
                  - rm app/var/test.db 
                  - php app/console --env=test doctrine:database:drop --force
                  - php app/console --env=test doctrine:database:create --force
                  - php app/console --env=test doctrine:schema:update --force
                  - cp app/var/test.db app/var/test.initial.db
                  - { command: 'phantomjs-1.9.7-linux-x86_64/bin/phantomjs" --webdriver=4444  >"phantomjs.log"', background: true }
              beforeFeature:
                  - cp app/var/test.initial.db app/var/test.db