Suppose you’re using Visual Studio 2008 and you’ve just found out that Microsoft added unit test support for the Compact Framework on devices and emulators. Neat-o!
So you add one to your project thinking, this’ll be fantastic.
Then it doesn’t work.
You get the following cryptic error:
Unable to set TestContext property for the class {class}. Error: System.ArgumentException: Object of type 'Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext' cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'
“So,” you think, “I obviously did something wrong, but it’s not apparent to me what I did. I will check the Google.”
But Google only shows you what to do for the full framework.
Maybe it’s your project that’s screwed up. So you start a new one to see if it works. It doesn’t, but you get a different error: References root node unavailable. You might as well search the google for that one and then you get this forum post that repeats the solution over and over:
Restart the IDE.
You figure it can’t hurt, so you try it.
And it works.
You can now use unit tests for .NET CF projects, but you’re no longer smiling about it.
I also found that following these instructions proved to be useful:
http://msdn.microsoft.com/en-us/library/bb384146.aspx
In short: these were the crucial steps:
1. Double-click the file that is named SmartDeviceTestRun.testrunConfig in Solution Explorer.
2. Click Hosts.
3. Verify that Host type is set to Smart Device, Platform is set to Pocket PC 2003, and Device is set to Pocket PC 2003 SE Emulator.
I’m having the same issue with a VS2008 application for mobile devices, I could not find the test config file, the restart of the IDE did not work