NUnitLite V’s Visual Studio Testing for Devices

Most .NET developers would have heard of, or have used, NUnit for unit testing code.  Well, last week Charlie Poole made the first release of NUnitLite which is a cut down version that is compatible with not only the full .NET Framework but also all versions of the .NET Compact Framework.  Neil has already posted on how you can get started writing tests for your mobile code so I won’t bore you with that. What I wanted to do is just highlight the differences between using NUnitLite and the new support for device application testing that has been added to Visual Studio 2008.

Support for testing .NET Compact Framework code has been added to Visual Studio 2008 and is feature complete afaik in VS2008 Beta 2.  The biggest limitation, and imho a significant oversight by the product team, is that you have to have your device connected to the computer running visual studio 2008 for the entire duration of the test.  Clearly this means that you can’t test anything to do with connectivity, network availability, suspend/resume capability, application restart etc.  Whilst you can unit test a large proportion of your code this functionality really doesn’t add a huge amount of value.  In the past you could simply create a desktop project, include the same code files and run the tests on the desktop and be fairly confident that a pass on the desktop would equal a pass on the device.  The areas where this isn’t necessarily true are of course the boundary areas such as connectivity, battery life, suspend/resume behaviour etc – none of which can be tested with the included support for device testing.

This is where NUnitLife can come in handy – as it can be used to run tests on the device independently of the IDE it means you can disconnect the device, or even power off the device before, after or during test execution.  The results can be written to a file locally (as Neil illustrates in his post) and then manually reviewed at a later date.

What would have been good would have been for Microsoft to have built a device test runner that a series of tests could be sent to the device, executed at some point either straight away or after some initialisation had been completed and then the results sent back to the TFS server at some point in the future.  This would allow true application testing on the device.

Leave a comment