Yesterday I’ve hauled the “big” laptop home from work and tried plugging the unofficial port of the NUnit unit testing framework for Silverlight into Windows Phone 7. Jeff Wilcox had added support for Windows Phone 7 into his Silverlight unit test framework bis from last May already, so it’s little surprise that there was not much of a problem.
I did not compile the whole of the NUnit port to the Windows Phone 7 runtime, but use the Silverlight 3 version that references the May 2010 unit testing framework. When these assemblies are referenced, Visual Studio complains that using a Silverlight assembly could lead to unpredictable behavior, but this does not apply to this project. Firstly, the major differences are really close to the user interface, and NUnit does not render anything anywhere, it does not even reference anything Silverlight-specific types. Secondly, the whole test suite runs without errors. Compiling the NUnit framework to the WP7 runtime would be totally feasible, but any test project on WP7 needs to reference the Silverlight unit testing framework, which is a Silverlight 3 assembly. You’ll get the warnings about unpredictable behavior anyway.
The documentation on ho to run NUnit tests on Windows Phone 7 is on the Coogle Code Wiki. The project’s binaries have not changed, but I’ve added a version of the NUnit test suite for Wp7 that you can find in the code.