acquia / drupal-spec-tool
一个用于指定Drupal架构细节并生成自动化测试的工具
v6.2.0
2024-07-10 19:42 UTC
Requires
- php: >=8.1
- drupal/core: >=10.0.0-alpha1
- drupal/drupal-extension: dev-main
- traviscarden/behat-table-comparison: ^0.3
Suggests
- nickwilde1990/drupal-spec-tool-commands: Provides Composer commands to automatically populate/update Gherkin files as defined with this tool
This package is auto-updated.
Last update: 2024-09-06 13:15:32 UTC
README
本项目提供了一个用于指定Drupal架构细节并生成自动化测试的工具。它包括以下两部分:1) 一个Google表格,用于捕获规范并从中生成测试;2) Behat上下文,用于自动化生成的测试(示例)。
入门指南
Google表格
将当前Google表格复制到您的Google Drive
Behat测试
-
安装Behat上下文
composer require --dev acquia/drupal-spec-tool
-
将新上下文添加到您的Behat配置中,例如:
# behat.yml default: suites: default: contexts: - Acquia\DrupalSpecTool\Context\AccessControlContext - Acquia\DrupalSpecTool\Context\ContentModelContext - Acquia\DrupalSpecTool\Context\MediaContext - Acquia\DrupalSpecTool\Context\MenuContext - Acquia\DrupalSpecTool\Context\ViewsContext - Acquia\DrupalSpecTool\Context\WorkflowContext
-
复制默认特征文件(表示Lightning的出厂配置),到您的功能目录。例如,对于一个基于BLT的项目
mkdir -p tests/behat/features/drupal-spec-tool cp vendor/acquia/drupal-spec-tool/features/*.feature tests/behat/features/drupal-spec-tool/
-
随着您更改规范,使用Google表格“Behat”标签上生成的Gherkin更新功能。 (有关自动执行此过程的信息,请参阅下面的高级部分。)
-
运行Behat!如果测试通过,则您的应用程序符合规范。如果不通过,则根据您的需求更改其中一个或两个。
用法
在Acquia开发者中心的公告博客文章中了解更多关于工具功能和最佳实践的用法。
自定义
您可以通过扩展和替换默认上下文类来补充或覆盖出厂行为,例如:
namespace AcmeCorp; class CustomContentModelContext extends Acquia\DrupalSpecTool\Context\ContentModelContext { /** * Override existing functionality. * * @Then exactly the following content entity type bundles should exist */ public function assertBundles(TableNode $expected) { // ... } /** * Add new functionality. * * @Then something new should be true */ public function assertSomethingNew(TableNode $expected) { // ... } }
# behat.yml default: suites: default: contexts: - - Acquia\DrupalSpecTool\Context\ContentModelContext + - AcmeCorp\CustomContentModelContext
支持工具
社区已经提供了一些工具来构建在Drupal Spec Tool之上
- Drupal Spec Tool Commands - 提供命令以自动更新Google表格以匹配现有的Drupal站点。这对于在现有项目上添加Drupal Spec Tool非常有用。
- Drupal Entity Generator (DEG) - 根据Google表格自动生成Drupal配置,即“反过来”更新您的Drupal站点以匹配您的规范。
已知问题
贡献
欢迎贡献!请参阅CONTRIBUTING.md。
许可证
版权(C)2018 Acquia,Inc。
本程序是免费软件:您可以在自由软件基金会发布的GNU通用公共许可证的条款下重新分发和/或修改该程序,许可证版本为2。
本程序分发是出于希望它可能会被有用,但不提供任何保证;甚至不提供关于其商业性或适用于特定目的的暗示性保证。有关更多详细信息,请参阅GNU通用公共许可证。