Unit testing with Silverlight

image One of the things I was most excited about when we shipped the Silverlight 2 Beta 1 controls was the included unit testing harness, written by Jeff Wilcox.  I think it's a good thing when we can share some of our internal tooling.  It's good for customers, because they can leverage the work that we've been doing, and it's good for people here because it gives them a chance to "ship" something and get some visibility in the industry.  And this is definitely the case with the Silverlight Unit Test Framework, which Jeff has just updated for RC0.

This is the exact package that we're using internally to run our automated unit tests and we've been adding features to it as our team grows.  Oftentimes, development teams here at Microsoft use a different testing harness from what the testing teams use (please don't ask...) and I'm keen to avoid that setup, and the Silverlight Unit Test Framework provides the functionality for both.  And that we're allowing customers to leverage it opens up some other possibilities that I'll get into later.  Note that the Silverlight Unit Test Framework is an unsupported toolset, not an official Microsoft product.

Some of you may be asking why we wrote our own unit testing harness instead of using something like nUnit or MbUnit.  The main reason is because the existing offerings were all written against the full .NET Framework.  Even though Silverlight is .NET code, it really is a different platform.  And it has some special needs due to the constraints on the type of reflection you can use (public only) and how you're able to instantiate and discover tests.  So we decided we needed a harness that was written fully in Silverlight and hosted the tests directly in the harness itself.  This has worked out well.

So if you're starting to get rolling with Silverlight, and you want to do some unit testing, definitely give the Silverlight Unit Test Framework a look.

More details here.