.Net Core 3 Worker Integration Tests

你说的曾经没有我的故事 提交于 2021-02-16 20:14:11

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/60796678/net-core-3-worker-integration-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!