WP7 Unit Testing - getting started

Print Content | More

Testing is important and it can save you lots of time, to successfully setup a WP7 Unit Test project I recommend you to first obtain the ‘NuGet Package Manager’ Visual Studio 2010 extension, it will make it a breeze to retrieve the latest version of libraries and packages and add a reference to them.

Here is a step by step guide on how to create your test project using the testing framework kindly provided to us by Jeff Wilcox:

  1. Open up Visual Studio and install NuGet if you do not have it: Tools –> Extension Manager, look for NuGet Package Manager in the Online Gallery.
  2. Create a new Windows Phone Application project, do not modify it right now.
  3. Use NuGet to get the latest version of the Unit Test framework for WP7, you can do it in two ways: 
        - for the ‘Tools’ menu chose ‘Library Package Manager’ and then ‘Manage NuGet Packages for Solution’
        - right click on the project you wish the package to be added to and select ‘Manage NuGet Packages’
  4. In the dialog that will open go to the Online section and look for ‘silverlight.unittest.wp7’
    NuGetSlUnitTestWP7
  5. click on ‘install’ to download and add the package to the selected project.
  6. it’s time to modify the test project following what’s written in the Test_Readme.txt file:
        - open up the MainPage.xaml and handle the ‘Loaded’ event
        - add the following line to the event to activate the test infrastructure: this.StartTestRunner();
  7. Done. Running the project you should see something like this:
    WP7ut1WP7ut2

You are now ready to write you own custom tests using a syntax and rules very similar the ones used by the MSTest suite that is already integrated in Visual Studio.



WP7, Unit Test

0 comments

Related Post

All fields are required and you must provide valid data in order to be able to comment on this post.


(will not be published)
(es: http://www.mysite.com)