Unit Testing Windows Phone 7 Applications

Must Read

Marketing Guide Book Your Guide to Marketing Books in the Christian Marketplace

Your Guide to Marketing Books in the Christian Marketplace is the essential handbook for publishers and authors seeking to...

Making Home Affordable Refinance Program

It is recommended you avail the benefits offered by the Making Home Affordable Program which is supported by the...

Black Friday Shopping Tips

Black Friday is a vicious time of the year - people want to start their Christmas shopping, and they...

Unit testing is the process of exercising individual business objects, state, and validation for your applications. A  comprehensive set of unit tests written before you develop the code, and executed regularly during the entire development cycle, help to ensure that individual components and services are performing correctly and providing valid results.

You can use a special version of the Silverlight Unit Testing Framework adapted for use with Silverlight 3 to run unit tests for Windows Phone 7 applications. You can obtain this from Jeff Wilcox’s site ( Jeff is a Senior Software Development Engineer at Microsoft on the Silverlight for Windows Phone team.

The Silverlight Unit Testing Framework adds the Silverlight Unit Test Application templates to the New Project dialog box in Visual Studio and Visual Studio Express, and you can use this to add a test project to your application. The framework allows you to execute tests that carry the standard Visual Studio test attributes and include the standard test assertions such as IsTrue and IsNotNull. It can be used to run all the unit tests in a solution or selected tests; it reports the results on the phone, showing full details of each test that passed or failed.

You can also run tests on the desktop using a traditional test framework such as the Microsoft Test Framework (MSTest), instead of deploying the application to the phone or the emulator and running it there under the test framework. This is generally faster, but you must be aware that there are some differences in the execution environment, and tests may behave differently on the desktop when compared to running on the emulator or a physical device. When performing integration testing, you should run the tests on the emulator or a physical device.

There are some tests that you cannot run in an emulator. For example, you cannot test the Global Positioning System (GPS) or the accelerometer. In these cases, you may prefer to use alternative testing techniques, such as creating mock objects that represent the actual service or component that your application uses and substituting these for the physical service or component.

To view a video presentation about unit testing using the Silverlight Unit Testing Framework, see Unit Testing Silverlight and Windows Phone Applications on the Mix 10 website (

Automated Unit Testing

It is possible to automate testing on the Windows Phone 7 emulator if you need to implement a continuous integration process and build Windows Phone 7 projects on a separate build server that does not have the Windows Phone Developer Tools installed. This requires setting up a folder for the external dependencies and editing the project files. For more information, see the post, “Windows Phone 7 Continuous Integration,” on Justin Angel’s blog ( logPost=TFS2010WP7ContinuousIntegration).

It is also possible to automate building and deploying an application to a phone or emulator without using Visual Studio. This approach uses the Smart Device Connectivity API implemented in the assembly Microsoft.SmartDevice.Connectivity.dll. For more information about using this API, see “Smart Device Connectivity API
Reference” on MSDN ( and “Windows Phone 7 Emulator Automation” on Justin Angel’s blog (



Please enter your comment!
Please enter your name here

Latest News

Top 10 Provinces of Thailand Not to be missed for Travel

10 SuratthaniThe source of the proverbial Chaiya salted egg. Surat Thani is a province with many attractions,...

Underlight As Accent, For Power and The Main Light for Photography

Underlighting, in which fill or accent light comes from under the topic, is not widely used technique in the traditional Portraits, even though it will have...

How To Fix Overexposure As A Creative Tool, The Complete Guide

As an creative tool, overexposure is sort of underrated. What I’m close to propose could be a deliberate and well thought out technique for...

7D Mark II is Canon’s best DSLR cameras without full-frame sensor.

The expected long-awaited Canon EOS 7D Mark II are shipping in November for $ 1,799 without a lens. With a higher price tag, you...

Low key photography and How to isolate your subject.

Low key photography doesn’t depend on underexposure to make its point; the key to low key is that the majority of tones, even correctly...

More Articles Like This