简体   繁体   English

在微服务之间执行端到端测试时,如何隔离测试数据或测试流程?

[英]How to isolate test data or test flow when performing end to end tests between micro-services?

This might seem a little unorthodox way of doing things, but what we're trying to achieve is to find out a way to identify the flow as "test flow" when performing end to end tests in a live environment. 这可能看起来有些不合常规,但是我们试图实现的目标是找到一种在实时环境中执行端到端测试时将流程标识为“测试流程”的方法。

For example, in a e-commerce platform, let's say there are 3 components/microservices involved. 例如,在一个电子商务平台中,假设涉及3个组件/微服务。 (simplifying a lot) (简化很多)

  1. Product Authoring 产品创作
  2. Order Management 订单管理
  3. Fulfillment 履行

We want to perform an end to end test and be able to identify this work flow as a test, so that Fulfillment doesn't fulfill this order for real. 我们希望执行端到端测试,并能够将此工作流程识别为测试,以便实现无法真正实现此顺序。 For that matter, each component may choose to process this request a little differently. 为此,每个组件都可以选择不同地处理此请求。 The interaction between components are driven through Http requests and events. 组件之间的交互是通过Http请求和事件驱动的。

Hope I'm clear. 希望我明白。 Anyone has done this before or any suggestions around this ? 有人以前做过这个或有什么建议吗?

Thanks in advance. 提前致谢。

It is recommended that you write integration tests using fakes/test fixtures, here is a great article that explains: https://enterprisecraftsmanship.com/posts/integration-testing-or-how-to-sleep-well-at-nights/ 建议您使用假货/测试装置编写集成测试,这是一篇很棒的文章,解释了: https : //enterprisecraftsmanship.com/posts/integration-testing-or-how-to-sleep-well-at-nights/

Also, Martin Fowler's https://martinfowler.com/articles/microservice-testing/ 另外,马丁·福勒(Martin Fowler)的https://martinfowler.com/articles/microservice-testing/

Microservices need to communicate with other microservices to use external functionalities which means that those microservices should be in running state. 微服务需要与其他微服务通信以使用外部功能,这意味着这些微服务应处于运行状态。 This is an issue for designing tests since we need to control the output from external services, which we can't control at all. 这是设计测试的问题,因为我们需要控制外部服务的输出,而我们根本无法控制。 So maybe give Contract Testing a try instead of doing a whole flow end to end testing? 那么也许尝试一下Contract Testing而不是进行整个流程的end to end测试? Contract testing ensures that a pair of applications will work correctly together by checking each application in isolation to ensure the messages it sends or receives conform to a shared understanding that is documented in a "contract". 合同测试通过隔离检查每个应用程序以确保其发送或接收的消息符合“合同”中记录的共享理解,来确保一对应用程序可以正常工作。

I would recommend these articles &terms for your reference: 我建议这些文章和术语供您参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在两个微服务之间共享单个数据库连接 - Share single database connection between two micro-services 如何在 XUnit 中编写端到端测试 - How to write an end to end test in XUnit 如何系统/端到端测试一个.NET5 class库 - How to system / end-to-end test a NET5 class library 我怎样才能端到端地测试这个 .net 核心控制台应用程序? - How can I end to end test this .net core console application? 并行运行测试时如何管理测试数据 - How to manage test data when tests are running in parallel 如何在集成测试中组织测试数据 - how to organize test data in integration tests 如何在循环中收集断言并在测试结束时获得结果 - How collect Assert in loop and get result in end of test 如何计算通过失败测试用例并在执行结束时打印 - How to Count my pass fail test case and print at the end of execution 当Datagrid的滚动条滚动到末尾时,如何获得Caliburn Micro Action? - How do I get a Caliburn Micro Action when a Datagrid's scrollbar is scrolled to the end? SimpleInjector:在测试数据库上对控制器方法进行端到端测试 - SimpleInjector: End-to-end testing of controller's methods on a test database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM