NUnit async task fails "Method has non-void return value, but no result is expected"

Viewed 310

I'm running unit tests in ReSharper with NUnit 3.10.

I'm getting this error when doing a simple async test:

Method has non-void return value, but no result is expected

My test is literally:

[Test]
public async Task Nothing()
{
    await Task.Delay(100);
}

It says in the documentation that this is in fact the correct way to run async tests.

2 Answers

For those working in Unity, make sure you are using the updated Test Framework Package, at least 2.0.1. It is currently in pre-release so you will need to enable show pre-release in the Package Manager.

Documentation here for more about the feature.

For me the issues was that instead of using a NuGet package, the references were to a DLL that's compiled targeting .NET Framework 3.5. Using a NuGet package of NUnit fixed it.

Related