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
- Create a new Silverlight Unit Test Application project
- 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
- 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!
- Add [Fact] based tests and run the app
For Silverlight 3
- Create a new Silverlight Unit Test Application project
- In the project properties page, change the Target Silverlight Version from 4 to 3
- Remove the references to Microsoft.Silverlight.Testing.dll and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll (these are the Silverlight 4 versions)
- 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
- 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!
- 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
- Create a Windows Phone application
- 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
- 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)
- 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
- Add [Fact] based tests and run the app