Has anyone successfully managed to run unit tests for their Monotouch project? I have read other posts where people are told to manually add references to the appropriate assemblies. Doing this makes the project compile, but it will still not run the tests.
I have a solution with two projects; a Monotouch Navigation project and an NUnit Library Project. I added a reference to my monotouch project and to the monotouch and other needed assemblies to the test project. Tests that only runs code outside the monotouch assembly will run fine, the ones that accesses monotouch code fails with:
System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: The socket has been shut down at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags) [0x00000] in :0 at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in :0 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in :0 at System.IO.BufferedStream.Flush () [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.IO.BufferedStream:Flush () at System.IO.BufferedStream.Dispose (Boolean disposing) [0x00000] in :0 at System.IO.Stream.Close () [0x00000] in :0 at Mono.Remoting.Channels.Unix.ClientConnection.ProcessMessages () [0x00000] in :0
I found a post saying: "..if you're not running on the iPhone or in the iPhone simulator, there's no way to call the necessary native APIs to instantiate the components.."
So what I´m really wondering is if it´s actually possible to do unit testing in Monotouch at the moment, or if not, what all you other guys do?
Thanks!
You don't actually have to create a second solution, or pull out OS-agnostic code. There are a few tricks to it though. Generally:
Have written up a few details on what we have found to be best practice so far. You can find it here: http://ben.phegan.name/index.php/2011/02/28/monotouch-and-unit-testing.
Has anyone successfully managed to run unit tests for their Monotouch project?
Yes this is now possible with the latest MonoTouch 5.1.x (beta) releases.
I found a post saying: "..if you're not running on the iPhone or in the iPhone simulator, there's no way to call the necessary native APIs to instantiate the components.."
That's true. This is why a runner, executing on iOS (simulator or devices), was built to enable the execution of MonoTouch related unit tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With