问题
I've got a unit test in my MonoTouch project that I can't run from inside MonoDevelop -- it fails with "Unix transport error." Poking around on the web it looks like that's associated with the NUnit test runner blowing up, so I thought I'd try using the command-line test runner.
I used MonoDevelop's "Create Package" to build and package up all the DLLs, and then tried running my tests with nunit-console FooTest.dll
. This blows up, but I'm pretty sure it's not for the same reason it blows up inside MonoDevelop. The error message I get is:
** (/Library/Frameworks/Mono.framework/Versions/2.6.7/lib/mono/1.0/nunit-
console.exe:11174): WARNING **: The class System.Action`1 could not be loaded,
used in mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
File or assembly name FooTest, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null, or one of its dependencies, was not found.
I'm new to everything here -- NUnit, MonoTouch, MonoDevelop and .NET -- but it looks like I need to somehow configure NUnit to use the MonoTouch runtime environment. Is that it? And if so, how do I do that?
回答1:
There isn't a good way to use NUnit with MonoTouch.
- There isn't currently an NUnit test runner that will run on the iPhone or in the simulator
- You can test MonoTouch dlls with NUnit running on the Mac with Mono, but you can't use any iOS libraries from those assemblies. This means you can't test your controllers, only backend Model logic with no UIKit stuff.
Sorry, I have felt the same pain myself. I will post back if a solution ever surfaces.
回答2:
set $MONO_PATH to the nunit library to be able to run nunit-console. On my machine, the $MONO_PATH declaration is (in my .profile file):
MONO_PATH='/Applications/Beta/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/:$MONO_PATH'
来源:https://stackoverflow.com/questions/3877217/configuring-the-nunit-command-line-to-run-monotouch-tests