views:

405

answers:

4

Of course there's the Silverlight Unit Test Framework (which seems more like integration testing to me), this port of the NUnit.Framework assembly, and SilverUnit, but what other options are available for Silverlight unit testing?

Any good/bad experiences with any one of those (or others)?

A: 

I don't know if it works with Silverlight, but there's the test suite built right into Visual Studio 2008.

chedabob
You can't use traditional unit testing frameworks b/c they were not built against the Silverlight libraries. That's why Microsoft came up with the Silverlight Unit Test Framework.
scottmarlowe
+2  A: 

You can use the Silverlight Unit Testing Framework to do your testing. THere is an example here

There is also WebAii from Art Of Test. I haven't used this framework in anger but have managed to use it test the front end parts of a Silverlight Application.

AutomatedTester
Not having used it in anger is probably a good thing :-).
Robert Fraser
+7  A: 

The Silverlight Unit Testing Framework is an adaptation of the same metadata from Visual Studio's test framework. I developed it in my spare time a few years ago while working on the Silverlight team, and today we're shipping it a little more formally.

I recommend it simply because it is being used by so many teams inside and outside of Microsoft, and if you've used the existing test metadata, it all just works - no new learning.

Find it here:

  • It ships in the source code package for the Silverlight Toolkit, since the Silverlight Toolkit controls use this test framework. Find it in the "Binaries" folder.
  • Download the binaries at the MSDN code gallery page
  • The open-source (Ms-PL) code to the framework itself is available for download in the Silverlight Toolkit's source code enlistment.
  • More information, tutorials, and documents are available on my blog (sorry to link to myself here, but I am the Microsoft developer of the framework)

The framework does have limitations, unfortunately

Because of the security model for Silverlight Applications, the framework has less integration that the typical VS test suite: tests run inside the browser, are technically built Silverlight apps, and automation and code coverage are a bit of a challenge to get going.

But it's a first step in doing Silverlight development.

In the future, the test framework is actually going to become a proper part of the Silverlight Toolkit - additional tools including an automated test runner, build server integration, and even simple block-level code coverage will be released.

Jeff Wilcox
Thanks, Jeff. I recently started following your blog, esp with regard to Silverlight testing. It's good stuff. Guess what I'm really getting at is how to run automated unit tests against a silverlight class library. Is that possible w/the silverlight unit test framework?
scottmarlowe
Scott, yes. Sort of. There's a "TestService" client built into the product that can work with a local HTTP service to relay information and control the browser. We're going to try and publish these tools online, or in the Silverlight Toolkit, in the future. I'm sorry that it isn't documented well today, so stay tuned.
Jeff Wilcox
A: 

<3 NUnit. I've not used it for Silverlight yet, but it's easy to use, powerful, and has great support (a lot more than the Silverlight Unit Testing Framework). The best part about NUnit is how many utilities there are to go along with it -- because of the strong adoption as well as its JUnit compatibility in many areas, it's simple to integrate into your build process, get reports in many different formats, etc., etc.

Robert Fraser
I live by NUnit also, but unfortunately NUNit has not been compiled against the Silverlight framework so it cannot be used in a Silverlight project. They're saying it might come in v3.0, though.
scottmarlowe
Let me add, though, that you can use Jamie Cansdale's Silverlight NUnit port, but he didn't provide the converted source. http://weblogs.asp.net/nunitaddin/archive/2008/05/01/silverlight-nunit-projects.aspx?CommentPosted=true#commentmessage
scottmarlowe