Welcome to EMC Consulting Blogs Sign in | Join | Help

David Wynne's Blog

Getting Started with the Silverlight Unit Test Framework RC0

I’ve just started looking at how we can leverage Jeff Wilcox’s Silverlight Unit Testing Framework in the current Silverlight project I’m working on.  There are some pretty long (and good) posts on Jeff’s blog about the framework that contain all the information I’m about to tell you, but if you want to get going quickly with the latest version – here’s what you need to know.

If this is your first look at the framework, then Jeff’s post from March is a really good introduction to the top level benefits offered.  That post was written for the SL Beta 2 release (which contains 3 binaries and VS templates).  The RC0 release only contains 2 binaries and some breaking changes – Jeff has detailed the changes, but the headlines you care about for getting started are as follows:

  • There are now only 2 assemblies (Microsoft.Silverlight.Testing & Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight).  This is all you need.
  • The Project/Item templates from the Beta 2 release, don't add that much value and are aligned with pre-RC0 changes, so are best avoided at this point in time.
  • In your test project’s App.xaml cs Application_Startup() you no longer need to pass CreateTestPage() a reference to the application.
    • Example: this.RootVisual = UnitTestSystem.CreateTestPage();
      [ Previously you would have called CreateTestPage(this) ]
  • UI Tests, should now inherit from PresentationTest (not SilverlightTest)
  • Within UI Tests, TestSurface has been renamed to TestPanel
  • If you're writing anything that you want to be able to test, it cannot be private.  In Silverlight, you cannot use reflection to access private types and members [details].  To overcome this, you need to make methods you want to test (such as event handlers) internal, and add an InternalsVisibleTo attribute to the AssemblyInfo.cs in your target project, to allow the test project access.
    • Example: [assembly: InternalsVisibleTo("MyApp.Test")]

If this is your first look at the framework, then the “headlines” above may not appear to simplify much, but I promise they do.  If you’re still skeptical, here’s a 3 point plan:

  1. Read the post from March
  2. Download the RC0 release
  3. Where something from the post in March doesn’t make sense/fit with the code in front of you, refer to the list above.

So far, in my limited explorations, the RC0 release works without complaint against Silverlight RTW.

Published 15 October 2008 08:56 by David.Wynne
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Mark.Mann said:

sweet! share your thoughts about integration with the RTW build when you've bedded it in for a couple of weeks!

October 15, 2008 11:49

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems