Adoption of Microsoft.AspNetCore.Mvc.Testing for Worker service. It's compatible with .Net Core 3.1.
Pack WorkerService.Testing
project in nuget package and install it using your preferred way.
Add WorkerService.Testing
as a project reference to integration test project and import WorkerService.Testing.targets
. Add this line to the end of integration tests csproj
file:
<Import Project="../WorkerService.Testing/WorkerService.Testing.targets" />
The usage almost similar to Microsoft.AspNetCore.Mvc.Testing. The main difference is that you should call StartAsync()
method to start the host. Check WorkerService.Testing.IntegrationTests
project for usage example.