【问题标题】:Should I be testing an entire business flow in a MQ/Service architecture?我应该在 MQ/Service 架构中测试整个业务流程吗?
【发布时间】:2018-10-14 22:23:08
【问题描述】:

我正在尝试将发送电子邮件的代码解耦到一个单独的服务中,而 rabbitMQ 具有服务之间的通信方式。

目前,我有集成测试来测试我们的 HTTP 端点,如下所示:

1. Create fake data in a dockerized mysql container. So that the DB is in the correct state
2. Perform testable action such as: User needs to approve a contract
3. Expect that the `contract.status` is now `approved`
4. Query a local SMTP server (Mailhog) to see if the email is there
5. Expect that email subject/body contains what I'm expecting

现在我计划将消息队列放入其中。我还应该像这样编写集成测试吗?我应该如何编写测试,以便在执行此操作时仍然可以测试是否发送了电子邮件。

【问题讨论】:

    标签: testing rabbitmq integration-testing message-queue


    【解决方案1】:

    如果整个解决方案由您负责,您绝对应该为整个解决方案编写集成测试。

    正如Martin Fowler 所说:

    集成测试确定独立开发的软件单元在相互连接时是否正常工作。

    编写测试取决于您的具体实现。我认为无论是否存在 MQ,您都必须创建测试数据并执行操作(步骤 1 到 3)然后检查结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-15
      • 2022-01-02
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 2019-10-02
      • 2012-04-01
      相关资源
      最近更新 更多