I've set up a testing projects for my cross platform solution which currently targets Android and Win Phone. The solution contains a Core PCL and Platform specific Android and WinPhone projects. I've also created 3 test projects. The Core PCL targets the full .NET 4.5 Framework whilst the Win Phone and Android projects target their respective platforms. The Core PCL Test project uses the NUnit, the Android Test Project uses Xamarin.Android.NUnitLite and the WinPhone project uses the MS Test Platform. Using compiler directives I can share and link in the same test fixture across the different test projects. I'm also able to execute the test on the respective emulators and platforms. All seems fine, however I've running into an issue with async tests.
The test signature for a async method looks like this:
public async Task TestAsyncTableOrderBy()
This works fine when running on the full .NET 4.5 and Win Phone projects. However, when run on the Android Test Project I get a
Method has non-void return value, but no result is expected error. When I change the signature of the method to
public async void TestAsyncTableOrderBy()
it runs through successfully on the Android emulator. From reading through this blog post on Async support in NUnit (and NUnitLite) documentation I know that both
async void and
async Task is supported. However, it seems as if Xamarin.Android.NUnitLite only supports
The MS Test Plaform does not support
async void so to share the same test code across the projects, I have to use
async Task. Am I missing something obvious here?