问题
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