Search code examples
asp.net-core.net-core.net-core-3.0

.Net Core 3 Worker Integration Tests


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?


Solution

  • 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