Silverlight 3 unit test framework binaries available
Two weeks ago, I posted the July 2009 release of the Silverlight Unit Test Framework online for folks looking for updated bits. Of course, the real gem is the Silverlight 3 version. Now that Silverlight 3 has shipped, you should definitely look at moving forward to this great new version.
Download the binaries
I’ve updated the MSDN code site for the product with the Silverlight 3-specific binaries, for anyone that is interested.
103K, Zip: Direct link
MSDN Code Gallery web site for the framework
Find the binaries in the Silverlight Toolkit
If you’re using the Silverlight Toolkit July 2009 release for Silverlight 3, you’ve already got the Silverlight unit test framework binaries on your machine. They’re located in the source code package (Source code.zip).
Here’s how to track them down…
When installing the Silverlight Toolkit
Make sure that you keep the “Source Code” feature of the Silverlight Toolkit checked. That will place the zip package on your system with the source, plus the unit test framework binaries.
Locate the source code for the toolkit
Go ahead and find the zip package after installation, and extract it to your system somewhere.
Jump into the Binaries folder of the extracted package

Use the Silverlight unit test framework
And now you’re good to go. You’ll find the binaries in that folder, and you should add references to both Microsoft.Silverlight.Testing and then the unit test metadata assembly, Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
What’s new in the July 2009 bits of the Silverlight Unit Test Framework?
- Support for the [Timeout(...)] attribute on test methods.
- Improvements to the Test Service interface. The service now has an asynchronous reporting phase that allows for more robust automation options (details coming soon).
- Minor interface changes
- Minor bug fixes
No fundamental differences between the Silverlight 2 and 3 versions
There are no fundamental differences between the versions, and the Silverlight 2 version of the framework works fine with Silverlight 3 application development. But it makes sense to use the appropriate version.
Looking forward, we may move the unit test framework right into the Silverlight Toolkit, for ease of use.
Hope this helps!
>> Looking forward, we may move the unit test framework
>> right into the Silverlight Toolkit, for ease of use.
That would make a lot of sense.
Two quick questions:
On http://code.msdn.microsoft.com/silverlightut,
the “download new templates” button provides VS templates – I assume there are no changes to these for the latest UT framework update?
What is System.Reactive.dll? It is in the source tree’s binaries folder.
@Eamon,
Although the templates are not updated, I do need to do that. Although the code hookup mechanism has not changed, the Silverlight project files have evolved enough that I will try to update this at some point.
Reactive is a prototype assembly that allows some of the Silverlight Toolkit tests to have a more fluent nature to them.
So far so good!
Easy to set up and understand.
Request for article:
How to get this unit test framework to play with continuous integration as well as calculating test coverage? (i.e. by running in TFS or TeamCity, and speaking with nCover or such
Good fun framework. (I’m a jerk who loves unit testing)
Only problem I am having that when I was testing code that spawned a background worker that lead to some asserts that while they fired, errors in the background thread and the asserts have no effect on the overall unit test (a failed assertion resulted in a passed test).
Now my guess is that the UI thread has to do the assertions, however I am dealing with a Silverlight DLL atm and not a full blown app so I don’t have an easy way to get a dispatcher.
Now I don’t want to say “Gimme Dispatcher” but this overall issue is something to possibly look into. The Visual Studio Debugger stops on failed assertions so I have a workaround for now.
And I’m an idiot it seems, you have a whole other post that deals with that. Dunno how I missed it searching for info on what may be up.
Jeff,
I am wondering if you might have any suggestions on how one might go about building chained async events for testing.
i.e.
- New up an object and get its contents from a datasource
- Modify the previous object
- Save the object
- Ensure that its data saved correctly
I can get the async testing to work for this in separate parts but I’d like to be able to test the sequence of events. I’ve tried making private async methods and this didnt work, I’ve also trying enqueuing tasks on the callback function and these just blow through and aren’t really ‘reached’ in the traditional fashion. If you need more information let me know. Thanks.
@BigDubb,
For these scenarios, make sure to read the quick guide on async testing in the framework. What you should do is actually consider something like
- Adding a Timeout attribute, then calling TestComplete from the proper event handler you hook up
- Or, using a private bool or int to track the events being called, plus a delayed callback – EnqueueDelay – that checks and asserts that.
It isn’t perfect, but that might get you started in the right direction. If you examine the open source tests from the Silverlight Toolkit, you’ll see that we do some of this validation throughout the tests.
Thank you
I have problem that Unit Test project not work properly.
It seems like Test runtime can not find ServiceReferences.ClientConfig file.
Do you have any idea?
Test method DataAccessTest.SPStorageTest.GetSubDirectoriesTest threw exception: System.InvalidOperationException: ConfigFileMissing —> System.Xml.XmlException: Xml_InternalError.
System.Xml.XmlXapResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings)
System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup()
System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup()
System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Current()
System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
ctor(String endpointConfigurationName)
CreateSimplexFactory()
CreateChannelFactory()
CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
InitializeChannelFactoryRef()
ctor()
WebDesktopPrototyping.RefSPFolder.SiteDataSoapClient..ctor() in D:\Project\KT Web Desktop\WebDesktopPrototyping\WebDesktopPrototyping\Service References\RefSPFolder\Reference.cs: line 2625
WebDesktopPrototyping.Data.SPStorage.GetSubDirectories(String directoryUrl) in D:\Project\KT Web Desktop\WebDesktopPrototyping\WebDesktopPrototyping\Data\SPStorage.cs: line 278
DataAccessTest.SPStorageTest.GetSubDirectoriesTest() in D:\Project\KT Web Desktop\WebDesktopPrototyping\DataAccessTest\SPStorageTest.cs: line 84
Two suggestions:
1. It would be really nice if you included the Microsoft.Silverlight.Testing.xml file in the zip, such that we get the xml comments in intellisense. I downloaded the source files, checked the “xml documentation file” checkbox for the project and it works like a charm.
2. Some sort of documentation would be nice as well. Thorough documentation is perhaps too much to ask for, but an example of how to use the WorkItemTest class would be useful.
Jeff,
What’s the progress on the “more information” w.r.t the test automation picture. I’ve been waiting a few months now for more info on this to allow me to extract the test results and also for a better way to fire off the tests using a Continuous Integration solution.
Currently I have to resort to screen scraping the html page to report on the results! I’ve written a custom logger that I’ve plug into the testing framework, but I still don’t know how to export the results to show it on our build server.
Thanks
This information would be much appreciated.
Thanks Jeff! I was dying for some unit testing support for Silverlight, and this really does the trick!