Download the latest vesion from the Downloads tab.

Please be sure to "unblock" the downloaded zip file! (Right click -> Properties -> Unblock)

The easiest way to get started is to install the April 2010 Silverlight Toolkit. This adds a Silverlight Unit Test Application project template to the new project dialog in Visual Studio.

For Silverlight 4

  1. Create a new Silverlight Unit Test Application project
  2. Add a reference to the following files from the Silverlight4 folder in the zip file:
    • xunit-silverlight4.dll
    • xunit.extensions-silverlight4.dll
    • xunitcontrib.runner.silverlight.toolkit-silverlight4.dll
  3. IMPORTANT: In the App.xaml.cs file, before the call to UnitTestSystem.CreateTestPage add a call to UnitTestSystem.RegisterUnitTestProvider(new XunitContrib.Runner.Silverlight.Toolkit.UnitTestProvider()). If this step is missed, no tests will be found!
  4. Add [Fact] based tests and run the app

For Silverlight 3

  1. Create a new Silverlight Unit Test Application project
  2. In the project properties page, change the Target Silverlight Version from 4 to 3
  3. Remove the references to Microsoft.Silverlight.Testing.dll and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll (these are the Silverlight 4 versions)
  4. Add a reference to the following files from the Silverlight3 folder in the zip file:
    • Microsoft.Silverlight.Testing.dll (the Silverlight 3 version)
    • xunit-silverlight3.dll
    • xunit.extensions-silverlight3.dll
    • xunitcontrib.runner.silverlight.toolkit-silverlight3.dll
  5. IMPORTANT: In the App.xaml.cs file, before the call to UnitTestSystem.CreateTestPage add a call to UnitTestSystem.RegisterUnitTestProvider(new XunitContrib.Runner.Silverlight.Toolkit.UnitTestProvider()). If this step is missed, no tests will be found!
  6. Add [Fact] based tests and run the app

For Windows Phone 7

The steps for Windows Phone 7 are ostensibly the same as for Silverlight 3. Follow along with this blog post
  1. Create a Windows Phone application
  2. Add references to
    • Microsoft.Silverlight.Testing.dll (Silverlight 3 version - included in release)
    • xunit-silverlight-wp7
    • xunit.extensions-silverlight-wp7
    • xunitcontrib.runner.silverlight.toolkit-wp7
    • Visual Studio may display warnings about including Silverlight 3 assemblies. Ignore it, these are the right files
  3. In the MainPage.xaml.cs file, modify MainPage_Loaded to create the test page and set it as the RootVisual (see the above link for more info)
  4. IMPORTANT: Ensure you register the unit test provider with a call to XunitContrib.Runner.Silverlight.Toolkit.UnitTestProvider.Register(). If you do not call this, NO TESTS WILL RUN
  5. Add [Fact] based tests and run the app

Last edited Mar 17, 2011 at 12:43 AM by mattellis, version 2