fit2ing/symfony-behat-services

此包的最新版本(1.0.3)没有可用的许可证信息。

1.0.3 2023-11-07 14:52 UTC

This package is auto-updated.

Last update: 2024-09-07 16:32:31 UTC


README

Symfony Behat Services Bundle 提供了一套用于在 Symfony 应用程序中管理和测试服务的工具。它允许您定义服务和它们的可用性,这对于测试某些服务可能不可用或暂时禁用的情况非常有用。

目录

介绍

在 Symfony 应用程序中测试服务可能具有挑战性,尤其是在处理不同的服务可用性场景时。Symfony Behat Services Bundle 简化了服务管理,并允许您在测试目的下控制它们的可用性。

安装

要将 Symfony Behat Services Bundle 包含到您的项目中,请按照以下步骤操作

  1. 通过 Composer 需求包

    composer require fittinq/symfony-behat-services
    

使用

添加服务

您可以使用类似于以下 Gherkin 场景来添加服务

   Given there are services
   | name    | url                |
   | service1 | http://service1.com |
   | service2 | http://service2.com |

标记服务为不可用

您可以使用类似于以下 Gherkin 场景来模拟服务不可用

  Given service1 is unavailable

配置

更新您的项目,以便在测试设置中包含 Behat 包。

    default:
       default:
       paths:
          - behat/features
       contexts:
          - Fittinq\Symfony\Behat\Service\Context\ServiceContext