Silverlight unit test framework download for Silverlight 2 Beta 2
9/15/08 Update: The Microsoft unit test framework now has its own MSDN Code Gallery site, where you’ll find the latest framework releases and other information. http://code.msdn.microsoft.com/silverlightut/
If you’re looking for the latest Silverlight unit test framework download, look no further: I’ve packaged up the binaries and am making them available as a .Zip file download attached to this blog post.
These are the same exact binaries that we shipped at the MIX conference for Beta 1 – there’s very little that changed for unit testing since Beta 1. Just a few days ago I posted the workaround steps and also updated Visual Studio 2008 test templates for Silverlight 2 Beta 2.
I had a great time meeting with customers at a recent “Ask the Experts” event in Redmond, thanks to everyone that attended, I received some great feedback on what people are looking forward to in the Silverlight testing space and will see what I can make happen!
Download the test framework
Download Microsoft.Silverlight.Testing.zip (160kb)
Installation instructions included in the Zip
Download the optional templates for Visual Studio
Unit test framework tutorial
My original walkthrough post will get you up and running in no time. Also, ScottGu’s original post about the test framework.
Hope this helps.


Jeff,
This framework is great. Do you have any guidance to include it as part of an MSBuild?
We have shared code between SL and the Full Fx and we also want to share Testing code, but we have problems with the private accessors, do you have any idea around this topic?
Thanks in advance.
Miguel
I went with the InternalsVisible, I guess is the way to do it in SL.
About the build’s support I saw is on your todo list.
Thanks
I have added the [ExpectedException] to some of my test methods but when I throw the exception from within my code visual studio will break on the exception and say “Unhandled exception thrown from user code”. Continuing on behaves as normally and the tests succeeds but I’d really like it if visual studio would not break on these exceptions. Is there any way to prevent this without disabling my ability to break on unintended unhandled exceptions?
I was just about to post on the same subject.
Options
To run your tests using Ctrl F5 (or Start Without Debugging), but you would probably want to debug other tests.
Disable Break when a User-unhandled exception is thrown (Ctrl-D-E) or Debug@@>Exceptions. Of course you would probably want to find out if other exceptions are thrown. One option is to let the test fail and then add a breakpoint to debug it.
Other option is to change Application_UnhandledException in app.xaml.cs, here you could add logic to check if this was about an expected exception, I dont think it would be an easy topic, I’m thinking about inspecting the stacktrace, if you dont mind hardcoding it that could be a solution.
I hope than once this Unit Testing Fx is integrated in VS we would have a better experience. The framework could easily (I guess) detect if an unhandled exception is thrown and this was inside a method with the ExceptedExceptionAttribute and then check if that’s the proper exception and mark it as handled. That would be something similar to what we could do on Application_UnhandledException method, but there is hard to know inside which TestMethod the exception was thrown.
Hello Jeff,
Any ETA on a silverlight controls test suite update for Silverlight 2.0 beta 2?
Thank You,
Jasonlan
Jasonlan,
I think that most of the teams are “heads down” focusing on getting Silverlight 2 ready, and that there won’t be a complete release of the tests for beta 2.
That said, the WatermarkedTextBox for Beta 2 is available on Kathy Kam’s blog (http://blogs.msdn.com/kathykam/archive/2008/06/23/watermarkedtextbox-for-silverlight-2-beta-2.aspx) and includes the unit tests for that control as well, and may be of interest to you.
-Jeff
Thanks for the framework, and I would like to echo Valerie’s dilemma, my templates are not showing up either, and I am on the C# root. I only see the option to search for an online template. Like Valerie I exited and restarted VS. I also copied the file into the language files under \ProjectTemplates\ and \ItemTemplates\ (in case that was the issue) with no luck.
Hi, I’m just playing with this for the first time and I’m finding the referenced instructions for wiring up the RootVisual require an additional cast to UIElement. It’s no big deal, but it makes me think I’ve got a version mismatch or something.
Here’s what the walkthrough gives:
this.RootVisual = UnitTestSystem.CreateTestPage(this);
but that gives a compiler error… instead I cast the right hand side to (UIElement).
[...] You can download that framework and Visual Studio 2008 template for Silverlight Unit Test from this link. If you are very new to SIlverlight Unit Testing, please take a look this [...]