Monotouch Unit Testing

Did you successfully run unit tests for your Monotouch project? I read other posts asking people to manually add links to related assemblies. Doing this makes the project compile, but it still won’t run the tests.

I have a solution with two projects; Monotouch navigation project and NUnit library project. I added a link to my monotouch project and to monotouch and other necessary assemblies for a test project. Tests that run only code outside the monotouch assembly will work fine, those that access the mono code will fail:

System.IO.IOException: write failure ---> System.Net.Sockets.SocketException: socket is disabled in System.Net.Sockets.Socket.Send (System.Byte [] buf, Int32 offset, Int32 size, SocketFlags flags) [ 0x00000] at: 0 in System.Net.Sockets.NetworkStream.Write (buffer System.Byte [], offset Int32, size Int32) [0x00000] at: 0 --- End of internal check of the exception stack --- in System.Net .Sockets.NetworkStream.Write (buffer System.Byte [], offset Int32, size Int32) [0x00000] at: 0 at System.IO.BufferedStream.Flush () [0x00000] at: 0 at (wrapper remoting-invoke-with -check) System.IO.BufferedStream: Flush () in System.IO.BufferedStream.Dispose (Boolean disposing) [0x00000] at: 0 in System.IO.Stream.Close () [0x00000] at: 0 in Mono.Remoting .Channels.Unix.ClientConnection.ProcessMessages () [0x00000] at: 0

I found the message : "If you are not working on the iPhone or in the iPhone simulator, you cannot call the necessary built-in APIs to instantiate the components."

So I really wonder if it is really possible to do unit testing in Monotouch at the moment, and if not, what are all the other guys doing?

Thank!

+3
source share
4 answers

In fact, you do not need to create a second solution or pull out OS-agnostic code. However, there are a few tricks. Usually:

  • Link to MonoTouch assemblies, even in your .Net 3.5 / Mono Test Projects
  • The Supervisor controller template helps with the amount of code you can verify.

, . : http://ben.phegan.name/index.php/2011/02/28/monotouch-and-unit-testing.

+2

Monotouch?

, MonoTouch 5.1.x().

, : " iPhone iPhone, API ".

. runner, iOS ( ), , MonoTouch.

+2

, . , :

  • OS-agnostic .
  • vanilla.NET 3.5.
  • .

(), , , MonoDroid. - , , .

0

, .

Xamarin , NUnitLite.

0

Source: https://habr.com/ru/post/1789713/


All Articles