MSDN Archive Home
Help and FAQs
Silverlight Unit Test Framework
All Resource Updates
Change History (all pages)
Microsoft Silverlight Unit Test Framework
The Microsoft Silverlight Unit Test Framework is a simple, extensible unit testing solution for Silverlight developers.
This test framework is a solution built by developers, for developers, to help get a jump start on building richer applications and components for Microsoft Silverlight 2.
More information about the Silverlight Unit Test Framework, including tutorials and articles, can be found at
The Microsoft unit test framework is one of several popular .NET unit testing metadata choices out there. Around since Visual Studio 2005, we decided to make it easier for everyone to get started in the Silverlight world by using the same metadata. The Silverlight unit test framework includes the same assertions and metadata that you'll find in Visual Studio 2008 Professional.
If you're new to Microsoft's effective and easy-to-use unit test framework, then you'll be able to use your Silverlight testing knowledge while building applications on the full .NET framework platform, including Windows Forms, WPF, and .NET 2.0 through 3.5 class libraries.
Sep 16 2008 at 5:40 AM
, version 9
Sep 24 2008 at 3:37 PM
I love using this to unit test our silverlight apps. Is there any chance that either a similar library will be released for WPF or the source code will be released? I think that the way that this library handles async UI unit testing would also be useful for WPF desktop applications as well.
Sep 25 2008 at 9:27 AM
@cobyjone, we're definitely looking into what it would take to release this project on CodePlex. Do stay tuned, I think it would be a great thing to see. - Jeff
Oct 17 2008 at 12:52 AM
the RTW download doesn't seem to contain the Microsoft.Silverlight.Testing.Framework. If you have installed the prebuilt templates (option 2, in http://www.jeff.wilcox.name/2008/03/31/silverlight2-unit-testing/ ) then you need to remove the call to InitializeComponent() in App.xaml.cs and also remove the parameter from UnitTestSystem.CreateTestPage() in the Application_Startup method. That done, you should be able to get to your first failing test. Will Stott
Oct 18 2008 at 10:14 AM
Thanks Will. We merged the 2 framework assemblies into a single one this time around, but haven't released the updated templates. I'll try and get those added, sorry!
Oct 23 2008 at 9:47 PM
Unit Testing is vital. The Silverlight Test Project is very helpful, but...
Will we see this integrated into VS.NET Unit Test IDE Tools? By this, I mean, can this project be updated in order to use in the Test View/Results items in VS.NET 2008, as well as support TFS Client Integration.
This is a key requirement, as across our Enterprise we all balance on MSF Workflow using the Foundation Server Tools (via TSF Build Exporer Client)
It has become increasingly difficult to maintain work items, associate test run stats and binaries to newly created items, etc.
Tell me what I can do to help, if this is not a feature that will be supported soon.
Jan 5 2009 at 3:32 PM
I enjoy your postings. Here is a use case that I feel is probably very common:
I am interested in a simple process for "unit testing" my WCF web services from Silverlight to make sure I have created the proper configuration. I am using a dual-targeting approach as outlined in CompositeWPF project on CodePlex.
I have done some digging and haven't found a simple answer, so I am resorting to a simple Silverlight application and companion web application to perform the tests.
It would also be very nice if I could just link in the test classes from the WPF unit testing project.
Jan 20 2009 at 1:23 PM
It's a great framework thank you very much but, I'm missing the Microsoft.Silverlight.Testing.Framework.dll in the release version. Don't we have to use this dll anymore? Also the project and class templates are not availble for release?
Do you have an indication when these templates are available?
Feb 24 2009 at 6:04 PM
Hey, thanks for this. I do have a problem though. Whenever I run the tests and anything fails the application throws an exception and breaks--obviously not desirable. How do I get around this?
Mar 17 2009 at 6:21 PM
I am having the same issue. If any of my assertions fail, the application breaks at the assertion error (e.g., If Assert.IsNotNull(...) is false then the application breaks). How can I get the test framework to complete all the tests without breaking at an assertion failure?
Mar 17 2009 at 7:05 PM
I have setup this test class to not break at each exception, however it still breaks. Here is my code:
public class MainWindowTest: CustomFrameworkUnitTest
public void setInterceptUnhandledExceptionsTrue()
InterceptUnhandledExceptions = true;
public void failure1()
Assert.IsFalse(true, "Should be false");
catch (Exception ex)
public void falure2()
Assert.IsTrue(false, "should be true");
Neither of these work arounds have worked.
Apr 8 2009 at 8:39 AM
Has anyone got this framework working with the Silverlight 3 Beta? It doesn't seem to be able to resolve styles in the application resources.
May 2 2009 at 7:38 PM
Is it a known issue: Application is breaking when any assertion fails? Your immediated comment is appreciated. I tried with SL 2 and SL 3, I am getting the same results.
May 15 2009 at 7:19 AM
It is not working for me. When I run the test project, the browser just displays a message saying that the TestPage.html page is not found. Isn't this page supposed to be created dinamically?
May 15 2009 at 8:23 AM
Additional information: when I try to build (not run) the solution (which contains just the Silverlight test project and a Silverlight class library), I get this compilation error: "Unexpected error in task 'ValidateXaml': parameter 'message' can't be null".
May 15 2009 at 3:47 PM
Would like to run our Silverlight unit tests as part of a nightly build. Do I need to somehow host the build SL unittest project in Casini/IIS, hit the browser and screen-scrape or are there a nicer way? Does anybody have experiences with this?
Jun 15 2009 at 12:37 AM
If you run the project in without debugging mode (ctrl + f5) or right click on the test web page and select option "View Browser", shoud work.
Jul 14 2009 at 1:16 AM
@sorenenemaerke, I'm working to get the test automation solution released that we use with this framework for our nightly builds on the Silverlight Toolkit. Unfortunately these things take time.
Jul 28 2009 at 10:55 PM
@jeffwilcox @sorenenemaerke, Integrating with Visual Studio and TFS and being able to automate running Silverlight tests would be a big win for our team too.
Aug 8 2009 at 11:11 PM
I've just downloaded/installed the various components for the framework for Silverlight 3. Writing my first test cost me about an hour because the ItemTemplate does *not* derive the test class from SilverlightTest! I searched high and low to find out why the heck EnqueueTestComplete() was undefined. The ItemTemplate also lacks a using for Microsoft.Silverlight.Testing namespace.
So, is there a forum somewhere so that users of this software might collaborate and share their successes and failures?
In any case, thanks for making this available. I assure you, my solution for unit testing async methods was a *lot* less elegant than yours!
Aug 12 2009 at 8:02 AM
The project template hasn't been updated to reflect the new assembly versions.
Aug 28 2009 at 5:55 PM
Can somebody guide me how to debug a single test case. I have 100 test cases and in order to debug one, i need all of them to execute. Is there any way out where i can only debug a single test case?
Aug 29 2009 at 2:13 AM
Is there a way (hopefully a fairly simple way) to impersonate a different user for a unit test? Either for a specific TestMethod or impersonate a user for all the TestMethods in a TestClass.
The Microsoft.VisualStudio.TestTools.UnitTesting.Web namespace has the CredentialAttribute, but that's not available in Microsoft.Silverlight.Testing.
Sep 10 2009 at 2:25 PM
Not to put a damper on the hard work that I'm sure went into this.... but until automation is available, it is akin to eye candy... useless in real life. I'm looking forward to when this is added, but until then must look elsewhere.
Sep 30 2009 at 6:28 AM
This doesn't compile for Silverlight v3.
Error 1 The name 'InitializeComponent' does not exist in the current context ...\SilverlightUnitTests\App.xaml.cs
Error 3 Argument '1': cannot convert from 'SilverlightUnitTests.App' to 'Microsoft.Silverlight.Testing.UnitTestSettings' ...\SilverlightUnitTests\App.xaml.cs
Here's the file created from the blog description:
public partial class App : Application
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
private void Application_Startup(object sender, StartupEventArgs e)
// Load the main control
this.RootVisual = UnitTestSystem.CreateTestPage(this);
private void Application_Exit(object sender, EventArgs e)
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
Oct 13 2009 at 3:28 PM
@jeffwilcox I love this framework! I have AutomationUI working against a WCF service using a delay timer, Async methods, and a ButtonAutomationPeer, but have also implemented a Silverlight Init Paramater (retrieved in App.xaml.cs) to self-locate the back-end Web Service in the real application. Has there been any thought to opening up the TestPage.html creation, giving the test author access to the Silverlight Object tag (before/during creation of the TestPage.html) in order to inject an Init Parameter using the Page.Request object to get the url of the service? If I missed something in the docs, please illuminate! Thanks again.
Oct 20 2009 at 5:32 PM
Just wanted to throw out the comment that I love this framework. One question though, and this has nothing to do with the actual framework, but I was looking at the screenshot on this page and I noticed the caption: "Sample rich test application running inside of the Apple Safari browser on Mac OS X 10.5" Isn't that actually Firefox not Safari? :)
Nov 5 2009 at 12:26 AM
The link to the Breaking Changes Information on this page is Broken. Please fix. Thanks.
Dec 1 2009 at 10:24 PM
I have 200 test cases written in Silver light test framework. I could not find a way to run or debug test cases individusally? Is there any way that i can run/debug a single test case at once??Please help this is bothering me since long time.
Apr 5 2010 at 5:03 PM
Will this framework support asynchronous testing from silverlight? If not can you recommend some framework that supports this...
Jun 14 2010 at 7:48 AM
On the result page of test method, there are informations such as:
Do I have access to this last section "Output"? Can I add message to it from my test methods? If yes, please tell how. Thanks.
Jul 17 2010 at 1:07 PM
I've written an article based on latest beta for using sl unit test in framework and mvvm light with sample code
Sep 1 2010 at 10:32 AM
I have a problem. I installed the Toolkit but I have no Silverlight Test Project in My Templates.
Why is this happening?
Oct 14 2010 at 7:45 PM
@jeffwilcox, any update on providing a mechanism to run Silverlight Unit Test Framework projects via msbuild?
Feb 22 2011 at 6:06 PM
Hello, I was wondering when silverlight unit testing will be integrated with TFS so that we can execute the tests via Test View in Visual Studio 2010? What is the current plan to support this? Without this, it is difficult to map our unit tests to associated product backlog items in TFS. Thanks.
Mar 12 2011 at 12:04 AM
Hi Jeff Firstly, I love the unit testing framework what a difference this has made to our product. I have a small new feature request for you. Where the classes are shown on the left after they have been unit tested could you postfix the number of tests in that particular class in brackets?
Jul 14 2011 at 3:41 PM
A couple quick questions:
1) would you expect a test to fail if a TestInitialize method throws an exception?
2) is there any way to use asynchronous (EnqueueXXX) methods in TestInitialize and TestCleanup?
On another note, is there any forum somewhere where people could discuss SUTF issues?
Jun 22 2012 at 11:41 AM
I could not find a way to run or debug test cases individually in silverlight unit test framwork.
can you please guide on the same and Could you please provide example from scratch to automate Silverlight 4 application.
Sign in to add a comment
Now in the Silverlight...
Fri Feb 12 2010 at 8:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.