We are busy preparing the long awaited beta release of NUnit 3.0 that should ship this week, but I’ve also been working on NUnit 3 runners for Android and iOS using Xamarin. It is still early days, but it is working fairly well, so I wanted to show it off and hopefully get some feedback on it. Windows phone will follow shortly and I will update it to support other platforms like Windows Store when Xamarin’s support moves from early preview to beta.
The following is the current process.
1. Creates a Xamarin Android or iOS application project. I hope to create a project template eventually.
2. Reference nunit.runner and nunit.framework in the project. It will be a NuGet package with the correct Xamarin dependencies.
3. In MainActivity.OnCreate() on Android or AppDelegate.FinishedLaunching() on iOS, swap the App object with the one we provide.
protected override void OnCreate(Bundle bundle)
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
return base.FinishedLaunching(app, options);
4. Write unit tests in the current assembly, or if you have tests in another referenced assembly, add those assemblies in App.AddTest(Assembly testAssembly).
5. Build and deploy the test app. When you launch it, it looks like this. The icon is generic because it comes from the project you created. If I create a template, then I will replace it with the NUnit icon.
6. Click the Run Tests button.
7. You get the typical overall summary of the test run. You can then drill down into just the failed or all tests. I might change the wording on those bottom buttons.
8. You see a scrolling list of all tests. The colored text is the test name. I just named some Fail, Error, etc so I could quickly eyeball mistakes You can then drill down into the individual tests for more information.
Of course, you can navigate up and down the stack and re-run tests. Some frameworks allow you to re-run individual tests. I’m not sure how useful that is, so I am holding off on that.