views:

423

answers:

3

I'm looking to create some Silverlight unit tests. I've started by downloading the Silverlight Toolkit and looking at the unit tests there which are all built on the Silverlight Unit Testing Framework.

However it seems that the test class structure is quite complex in the source and I don't want to re-write the test classes defined in that package (e.g. ControlTest->FrameworkElementTest->TestBase->SilverlightTest inheritance chain is defined and only the last class is all defined in the Silverlight Toolkit).

I'm looking for a code sample of the simplest unit test implementation possible with the Silverlight Unit Test Framework (e.g. executing Assert.IsTrue(true)).

+1  A: 

I did a whole talk on this. it has some "simple" examples of using that framework, but I have to tell you - it ain't pretty! Using MS SL Test and SilverUnit

RoyOsherove
Could you provide a link to the source code? On the video code is unreadable.
Gergely Orosz
The tests in the toolkit are unfortunately too complex for their own good. A regular VS test tutorial will be much more valuable to actually writing good tests. Due to resource limitations, much of the toolkit testing falls on the developers to create dirty end-to-end tests and integration tests that should really not be done in a unit test form :-)
Jeff Wilcox
+2  A: 

I'm surprised Jeff Wilcox didn't link to his own article!

This is the one that I used to set up my tests in Silverlight:

http://www.jeff.wilcox.name/2008/03/silverlight2-unit-testing/#option2

It was originally written for Silverlight 2, but I got it working under 3 with no issues.

Chris Jaynes
That's the "easy option on Jeff's site. The top of the page has the "manual" option, too. Both are worth reading.
Chris Jaynes
+2  A: 

Just for information, Visual Studio 2010 beta 2 has Silverlight unit testing out of the box. Maybe you want to take a look.

Konamiman