Has anyone had success using NCrunch testing with the long running Hosting.IHostedService Background tasks in .NET Core 2.2?
I have a .NET Core 2.2 web application that has a hosted service (only one) to run tasks during the lifetime of the web application.
The two problems that I'm seeing (which are related) are
- In Visual Studio (2019), NCrunch starts a new background task with each integration test run and the background task never exits when the test is finished.
- When the TeamCity environment runs the NCrunch integration tests, they never finish and the build step never completes.
I was going to try to use the code below, from the documentation, but it wasn't working for me.
Code:
if (Environment.GetEnvironmentVariable("NCrunch") == "1")
{
Console.WriteLine("Running under NCrunch");
}
else
{
Console.WriteLine("Running under something else");
}
Any suggestions would be greatly appreciated.
Thanks!
Alan
Visual Studio 2019 version 16.3.4
NCrunch 3.31.0.3
ReSharper Ultimate 2019.2.2
NDepend 2019.2.7