I’ve been writing some tests and I got this message:
[RIDER LOGO] Unit Test Runner
The process ReSharperTestRunner64:26252 has finished running tests assigned to it, but is still running.
Possible reasons are incorrect asynchronous code or lengthy test resource disposal. If test cleanup is expected to be slow, please extend the wait timout in the Unit Testing options page.
It turns out that because I was setting up an
IHost as part of my test (via a
WebApplicationFactory) that it was what was causing issues. Normally, it would hang around until the application is told to terminate, but nothing in the tests was telling it to terminate.
The culprit was this line of code:
var factory = new WebApplicationFactory<Startup>().WithWebHostBuilder();
factory is disposable and I wasn’t calling
Dispose() explicitly, or implicitly via a
The fix to this was simply to wrap the returned
WebApplicationFactory<T> in a using block and the test running completed in a timely manner at the end of the tests.
using var factory = new WebApplicationFactory<Startup>()
or, if by preference, or using an older version of C#:
using (var factory = new WebApplicationFactory<Startup>().WithWebHostBuilder())
// do stuff with the factory
Although this was running in JetBrains Rider, it uses ReSharper under the hood, so I’m assuming this issue happens with ReSharper running in Visual Studio too.