Mono for Android: Which Testing Frameworks work

2019-02-14 21:43发布

问题:

I have created a Mono for Android VS2010 project and added NUnit tests.

It seems Mono for Android does not support NUnit according to this post from Xamarin: https://bugzilla.novell.com/show_bug.cgi?id=644813

Are there any testing frameworks that do run when in a Mono for Android project?

回答1:

no, nunit does not work nor do any other frameworks. the intent of monodroid and monotouch is to provide a .net development environment that allows you to easily port business logic between different environments. as a result you can't really test android/ios specific code, but you can test generic .net business logic code. in the monodroid projects that i write, i create 3 projects in the solution, one is the android project, another is a .net library that holds all of my non-android specific logic and the final project is a nUnit test library against the .net library. I then add my logic code files into the android project with linked files. monodroid project files can not be tested, but .net codes files linked into monodroid projects can be tested with what ever framework you choose.



回答2:

There is now a Mono for Android test runner for NUnitLite (0.6). This allows you to run some (or all) your unit tests inside the emulator or on device(s).

It's very similar to Touch.Unit which provides a runner for MonoTouch on iPhones and iPads (iOS) and feature parity is planned (i.e. adding the network logging).

Disclaimer: I wrote the runner (but the most interesting code is NUnitLite and the, several times forked, MonoDroid.Dialog library ;-).



回答3:

For UI testing on actual devices, LessPainful announced earlier today that Calabash for Android supports it since version 0.1.0:

[...] we now support Mono for Android.

[...] Currently you can only test Release builds of your app. If you need to test Debug builds let me know.

I've not used Calabash with Mono.



回答4:

I created a version of NUnitLite that targets MonoDroid. It's worked quite well for me so far.

It needs to run directly on the emulator or device at the moment. If someone were able and inclined to write a runner for it, I'd welcome the input.

Check it out here: https://github.com/SpiritMachine/NUnitLite.MonoDroid