【发布时间】:2023-01-02 14:43:06
【问题描述】:
我已经实施了一个microservices-based 项目。 API gateway(用 .Net Core 编写)中有多个端点,我想测试这些端点。我有一个名为功能测试的项目,我测试需要多个服务才能工作的流程。
我正在使用 TestServer 对不同的服务进行 http 调用,我主要使用这些服务来检查 IntegrationEvents 是否得到正确处理,但我不能将它用于 API gateway 端点:
using Microsoft.AspNetCore.TestHost.TestServer identityServer = new IdentityScenariosBase().CreateServer();
using Microsoft.AspNetCore.TestHost.TestServer productServer = new ProductScenariosBase().CreateServer();
HttpClient identityClient = identityServer.CreateClient();
HttpClient productClient = productServer .CreateClient();
// Some other codes
而且我知道,作为一种替代方法,我可以在像上面的代码示例这样的测试方法中调用 API gateway 端点的所有进程,但我想对一个端点进行一个简单的 http 调用在API gateway 并得到结果。
【问题讨论】:
标签: c# asp.net-core microservices integration-testing api-gateway