Test Driving My Windows Phone 7 App
Published 7/24/2011 5:47 PM by Toran Billups 2 Comments
I recently started building my first WP7 app and found that most of the community seems to be "okay" with running tests through the emulator instead of a normal test runner like ReSharper. And as someone who can’t design software anymore without thinking test-first I had to come up with a way to test drive my app or I wouldn’t have much success on the platform.
I initially played around with the Silverlight NUnit Project Visual Studio Template but it didn’t work right out of the box as I had hoped. But not because Jamie Cansdale wasn’t thinking ahead, instead the latest version of ReSharper (6.0) has a bug in the test runner causing my tests to not go green (or red for that matter). So after a week without tdd, I went to the community for help ... but I still didn’t find the answer I was looking for.
Finally I decided to research and blog about the working solution I came up with that allowed me to practice tdd again on the platform. The video is 16 minutes long and I hope someone as frustrated as I was will find it helpful.
For anyone who isn’t interested in the short video I basically took the NUnit dll from the Silverlight NUnit Project and added it to a new WP7 Class Library. From here I had to downgrade my version of ReSharper to 5.x (until the test runner gets a patch). And finally if you come across the "assembly xyz is missing" during a unit test be sure you mark the dependency as "Copy Local - True"
If anyone wants the nunit dll I used in the project it’s available here for direct download.
Hello Toran, I have been trying out a test driven way of writing WP7 apps myself and experienced the same problem while using ReSharper 6. I filed the issue in their bug tracking list (RSRP-273830 unit tests stay grey). You can read about my experiences at: http://proq.blogspot.com/2011/04/unit-test-windows-phone-7-project.html Kind regards, Gitte.
Thanks for the interesting post. I had the same problem with ReSharper 6, which is unfortunate because otherwise the new version offers nice new features. I'm not sure if you are familiar with AgUnit, which is a plugin for the ReSharper 6. I'm quite sure that this plugin nowadays allows you to run your NUnit Silverlight tests with ReSharper 6. And who knows, maybe the ReSharper 6.1 helps with this problem too. Keep up the good work.