boga881 / drupal-spec-tool
一个用于指定 Drupal 架构细节并生成自动化测试的工具
dev-develop / 6.x-dev
2023-02-15 23:19 UTC
Requires
- php: ^8.1
- boga881/drupal-extension: dev-master
- drupal/core: ^9.4 || ^10.0.0-alpha1
- 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-16 02:38:43 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 规范工具
- Drupal Spec Tool Commands - 提供命令以自动更新 Google 表格以匹配现有 Drupal 网站。这对于在现有项目中添加 Drupal Spec Tool 非常有帮助。
- Drupal Entity Generator (DEG) - 根据谷歌表格自动生成 Drupal 配置,即 "反过来" 并更新您的 Drupal 网站以匹配您的规范。
已知问题
贡献
欢迎贡献!请参阅 CONTRIBUTING.md。
许可证
版权所有 (C) 2018 Acquia, Inc.
本程序是免费软件:您可以按照自由软件基金会发布的 GNU 通用公共许可证第 2 版的条款重新分发和/或修改它。
本程序以希望它能被使用,但没有任何保证;甚至没有关于其商业性或特定用途适用性的暗示性保证。有关更多信息,请参阅GNU通用公共许可证。