Silverlight unit test project templates

In my introductory post about the Silverlight unit testing work we’ve done, I also included some Visual Studio project and item templates that make it easier to add tests to your own apps and class libraries.  Here’s that information in one place:

Test Project

SilverlightTestProject.zip (8.8k)

To install the template, save this file into your “%userprofile%\Documents\Visual Studio 2008\Templates\ProjectTemplates” directory

This project template is used for adding tests to your existing Silverlight solution.  To use the test project once added to your project, simply right-click on it, set it as the ‘StartUp project’ and begin debugging.

Test Class

SilverlightTestClass.zip (8.0k)

To install, save this into “%userprofile%\Documents\Visual Studio 2008\Templates\ItemTemplates”

This is a simple test class template that includes the unit test metadata namespace, a sample test class, and a single inconclusive test method.

What hookup is performed by the test project

Test projects meet these conditions:

  • Are Silverlight application types, not class libaries
  • Reference the unit test framework assemblies built for Silverlight
  • Are packed up into a .Xap that itself includes the unit test framework assemblies
  • Do not contain Page.xaml or Page.xaml.cs files, instead the RootVisual is set to UnitTestSystem.CreateTestPage(this)
  • Typically just dynamically generates a test page, although you can use the development web server or an IIS/Apache installation just fine as well

Hope this helps!

Comments

  1. April 1st, 2008 | 9:07 am

    I found on your other post where it gets installed.
    * Click on the root “Visual C#” category
    * Select “Silverlight Test Class” and provide a name for your new class

    Thanks.

  2. September 3rd, 2008 | 8:00 am

    [...] It’s much easier to use Visual Studio project templates to do all the work above.  Previously posted about here. [...]