.Net Core 3 Worker 集成测试 [英] .Net Core 3 Worker Integration Tests

查看:30
本文介绍了.Net Core 3 Worker 集成测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 Asp.Net Core 应用程序的集成测试,我们有 WebApplicationFactory.但是如何测试不是 Web 应用程序的 Worker (HostedService)?我不想像这个问题.是否可以使用原始配置并覆盖一些依赖项,就像我们在 WebApplicationFactory.WithWebHostBuilder?

For integration testing Asp.Net Core application we have WebApplicationFactory. But how to test Worker (HostedService) that is not web application? I don't want to copy the whole DI configuration in SUT like in this question. Is it possible to use original configuration and override some of dependencies like we do for web application in WebApplicationFactory.WithWebHostBuilder?

推荐答案

我找不到任何用于 Worker 服务集成测试的解决方案,因此我采用了 WebApplicationFactory.源代码和使用示例可以在这里找到:https://github.com/gao-artur/WorkerService.Testing

I wasn't able to find any solution for Worker services integration testing hence I made adoption of WebApplicationFactory. The source code and usage example can be found here: https://github.com/gao-artur/WorkerService.Testing

这篇关于.Net Core 3 Worker 集成测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆