Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono Android. Unit test framework [closed]

Are there some unit test frameworks which supports mono android applications? I already tried default Visual Studio test framework and NUnit framework without any luck.
My last try: I created Mono Android class library, referenced nunit.framework, wrote tests. But when I tried to launch them I've got exception:

System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'mscorlib, Version=2.0.0.0'

Stack Trace:

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.Load(TestPackage package)
   at NUnit.Util.TestDomain.Load(TestPackage package)
   at NUnit.Util.TestLoader.LoadTest(String testName)

I'm sure that it's because of incompatibility of mono android assemblies with other assemblies...
So my question: How to put it to work? Or maybe there are some other unit tests frameworks for mono android applications?

UPD: Workaround for this issue.
Since I needed to test the platform independent models only I just created separate "proxy" Windows Class Library project and added to it links to model classes from my Mono for Android Class Library (Project => Add existing Item... => [select all files which should be added as links] => Add As Link).
So I received compatible with any Unit test framework assembly which consists of classes which should be tested.

like image 644
Igor V Savchenko Avatar asked Oct 11 '22 06:10

Igor V Savchenko


2 Answers

If you're look for running your Visual Studio Unit Tests under Mono for Android, I've written a compatibility layer for that together with a GUI.

Check it out here

Tests OverviewTests Details

like image 172
Sebastian Krysmanski Avatar answered Oct 14 '22 10:10

Sebastian Krysmanski


If you're looking to run your unit tests on devices (or inside the emulator) then you should have a look at Andr.Unit Mono for Android test runner for NUnitLite (0.6). It's similar (same UI and NUnitLite version) to Touch.Unit (iOS) even if it (currently) is a bit behind in terms of features (no network logging).

Disclaimer: I wrote the runner

like image 34
poupou Avatar answered Oct 14 '22 10:10

poupou