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

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

问题描述

对于集成测试Asp.Net Core应用程序,我们具有 WebApplicationFactory .但是,如何测试不是Web应用程序的 Worker ( HostedService )?我不想像此问题中那样在SUT中复制整个DI配置.是否可以使用原始配置并像在

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天全站免登陆