Paul Taylor's blog
Ramblings about technology, music and life...

Set up Silverlight 3 Unit Testing

Tuesday, 12 January 2010 00:57 by paul taylor

First things first, if you are new to Silverlight unit testing then I highly recommend checking out these excellent introductory videos.

Once you are armed with a bit of back ground leaning, follow these steps to get your machine up and running with the Silverlight 3 Unit Test Framework (assuming you have Visual Studio 2008 SP1 installed):

1) Download the Silverlight Project templates

Extract the file SilverlightTestProject_CSharp.zip to the directory:
C:\Users\<username>\Documents\Visual Studio 2008\Templates\ProjectTemplates
This installs the VS project template.

04-sltestproject

2) Extract the file SilverlightTestClass_CSharp.zip to the directory:
C:\Users\<username>\Documents\Visual Studio 2008\Templates\ItemTemplates
This installs the VS Silverlight test class template.

 05-sltestclass

3) Download the latest version of the Silverlight Unit Test Framework

4) Add a test project to your solution

  • Right-click on the solution
  • Select the Add > New Project menu item
  • Click on the root “Visual C#” project type node
  • Under “My Templates”, select “Silverlight Test Project” and give your test project a name.

5) Check the references in the test project created. If you have not extracted the Silverlight Test framework assemblies, you will see the following errors.

clip_image001[25]

6) Simply extract the 2 test assemblies:

  • Microsoft.Silverlight.Testing.dll
  • Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll

to your chosen directory and update the references to wherever the framework assemblies are extracted to. I personally have a ReferencedAssemblies\Silverlight folder where all shared assembles are stored within each project solution and add a Visual Studio Solution folder named SilverlightReferencedAssemblies

For reference, here is my initial solution folder

06-solution_with_testproject

7) Setting your newly created the test project as the StartUp project and running, should now allow your to run tests by pressing F5. You will get an error as no tests are in place but this shows all is setup ok.

clip_image001[35]

Here are a few more links to useful information on Silverlight unit testing

I hope this helps!

Tags:   , ,
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Comments

Comments are closed