×

First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

If you are a developer who likes various aspect of testing in your application (beyond the “does it work” testing), you may be interested in a few frameworks for Silverlight.

Microsoft Silverlight Unit Test Framework

This testing framework was developed by Jeff Wilcox of the Silverlight Toolkit fame among other things.  This test framework is used by the Silverlight Toolkit team themselves (as is what is shipped with the source code for the project).  This framework runs unit test inside the browser and includes the ability to test rich controls as well as the entire Silverlight platform.

Jeff has a great blog post which includes a video walk-through of this test framework.  Check it out: Silverlight Unit Test Framework.

SilverUnit

Just yesterday, Roy Osherove released SilverUnit, which he describes as

a new open source unit testing framework for Silverlight (true unit testing, not the Integration style, browser-backed, async-driven C#-only-friendly, monster of a Test Framework…”

Hmm, maybe we should have a death match at MIX between Jeff and Roy :-).  Reading the more detailed information about SilverUnit, Roy further describes:

You can run then as a regular NUnit test run, they run only in memory. The CThru engine underneath takes care of intercepting and “skipping” all calls to the silverlight runtime. SilverUnit does its part and mimics the missing pieces (Dependency Properties, RoutedEvents to a degree and so on).

The project is hosted on CodePlex as a part of the CThru project and you can get the bits and some demonstration there: SilverUnit.

Selenium

My friend Ted Neward turned me on to something new today: Silverlight-Selenium.  For those who don’t know Selenium, it is a very awesome web application testing framework, that is a bit of unit tests and a bit automation testing.  I personally have used Selenium for simulation of end-user interaction testing in web applications.  I think the framework is great and comes with some good tools to help record tests and automate the creation of scripts…but enough about that.

The new project extends Selenium a bit adding the ability for Silverlight communication.  If you are familiar with Selenium, you know that it uses JavaScript to communicate with the browser.  In order for this extension to Selenium to work with Silverlight, your code needs to be exposed as scriptable objects.  This is the only thing I see problematic with this framework.  I’m not sure that having a separate build for testing to add the [Scriptable] attributes will be palatable to most, but I’m sure there is some #IF DEBUG type stuff you could do to make that easier.

This project also includes “silvernium” (not sure that’s an actual element is it? ;-) in order to communicate with the Silverlight object model without you having to worry about that part.  This is an interesting project to watch.

Summary

Testing and patterns of testing vary.  I’ve seen many religious debates about TDD and what people think is right/wrong/whatever.  I’m not here to say anything on that – but that if you are testing beyond compiling and playing with it, that you should look at these types of frameworks evolving…they are easy to use and should be great additions to your development lifecycle. 

What else have you seen for Silverlight testing?


This work is licensed under a Creative Commons Attribution By license.


2/26/2009 12:00 PM | # re: Testing Silverlight Applications
Tim, please tell me that VS.net 2010 will include Performance Tuning and Unit Testing Integration for Silverlight Framework (just like 2.0, 3.0, and 3.5).

I have been running in circles with Debug.WriteLine and Performance Monitor trying to watch Memory/Instrumentation Metrics.

The plan was to build the Business layer in WPF then link over the files to Silverlight, but I am actually seeing different run-times for some very simular execution paths.

For instance, recursive calls for complex operations on a excel-like workbook with 500,000+ cells in silverlight are performing about 3 times slower than in WPF.

My only guess on this one is call-stack management. But, I don't know why a subset of 3.5 would be different in this area.

Another example of Silverlight specific difficulties is how/when memory is being cleaned up. In WPF, garbage collection seems to use a different 'strategy'.
2/26/2009 4:54 PM | # re: Testing Silverlight Applications
Konstantin thanks for keeping me honest! I did forget about that! I think this update though is more specific to actually including the Silverlight object model (silvernium) aspects.

I didn't know about Telerik's test suite -- is there a roadmap for Silverlight specific stuff or are you able to use it today with Silverlight with some tweaks?
2/27/2009 1:15 AM | # re: Testing Silverlight Applications
Hi Tim,

Yes, this Silvernium component is definitely something new. I was just curious if you remember the post by Scott..

Up to now WebUI Test Studio does not cover SL Apps. I can't say for sure when exactly it will operate with Silverlight. This support however is coming as sure as Silverlight 3. ;) As a tester who needs tons of automated functional tests, I'll definitely look for a quality record & play tool..

From the testing side, there is no such [Scriptable] requirement for testing with the WebAii framework. Instead, the API allows easy XAML searches of the elements in need. A great tutorial helped me with my first WebAii Silverlight tests some time ago:

community.artoftest.com/.../...upport-preview.aspx

BTW, a few months back I posted a list of UI Automation tools and resources for Silverlight 2:
blogs.telerik.com/.../...nd_resources_summary.aspx

I just hope the SL3 support for all these tools (WebAii, Selenium, UI Automation-specific) won't be too hard to achieve. The more solutions are available, the higher the quality. But that’s another story…

Thanks,
-Konstantin
2/27/2009 10:54 AM | # re: Testing Silverlight Applications
My biggest complaint about the silverlight unit test framework is the lack of automated tests, reporting and code coverage analysis.
2/27/2009 11:21 AM | # re: Testing Silverlight Applications
We use Microsoft Silverlight Unit test framework for test cases and it is good.
However I agree that it is hard to get these automated if possible.
2/27/2009 7:53 PM | # re: Testing Silverlight Applications
Because MVVM de-couples so well, we are going the route or writing the Model/ViewModel work in a non-SL assembly, and then referencing this into a SL assembly via linked files.

Because the actual non-View source is in a plain old vanilla standard .NET assembly we can then just use standard unit-testing frameworks against it (NUnit or Microsoft Testing Framework etc). No flashy hacks, or re-building test runners in the browser.

I haven't gone too far on this yet, so am yet to see where the wheels fall off. But this file linking strategy is employed by Prism, so this approach may not be too far out.

Does anyone have any criticisms of this approach. Be there dragons?
2/28/2009 7:17 AM | # re: Testing Silverlight Applications
NB: One of the potential downsides of this approach is the maintenance of the linking of files (ie. when the project file structure is changed, refactored etc).

BUT this is not a problem, with the tool the PRISM team developed to handle this:

Project Linker: Synchronization Tool
msdn.microsoft.com/en-us/library/dd458870.aspx

So I'm still hopeful and confident about this approach.
3/1/2009 3:43 AM | # re: Testing Silverlight Applications
@Morton, I hear you. Although it would be possible to get some automation and code coverage components out there and shared for the Silverlight unit test framework, I worry that they would not live up to the same level of quality that the test framework itself has.

But don't worry - your feedback is being heard loud and clear.

-Jeff
3/5/2009 3:57 PM | # re: Testing Silverlight Applications
So, the wheels mostly have fallen off this scheme for me. I'm dropping back to Jeff's system. Thanks Mr Wilcox.
3/12/2009 9:09 AM | # re: Testing Silverlight Applications
For enterprise applications, is there a plug-in available to be able to test Silverlight using HP Quick Test Pro or IBM Rational Functional Tester? Selenium is great, but I would like to be able to choose between tools.
3/12/2009 9:19 AM | # re: Testing Silverlight Applications
Nancy I'm not aware of how those tools operate to know if any of the above would integrate at all.
3/21/2009 6:39 AM | # re: Testing Silverlight Applications
Tim,

Will there be a release of CodeCoverage Support.Also at present none of the SilverLight Unittest framework outofthebox support continuos Integration .What I mean is today you cant call the Unitetst Assemblies from Script using Msbuild????

Unless there is a full fledge support available on this area Enterprise Developement on top of silverlight is looks bit tricky.
Gravatar
3/27/2009 3:33 AM | # re: Testing Silverlight Applications
An article on Unit testing Silverlight with SilverUnit was uploaded to:

www.typemock.com/Silverlight_unit_testing_page.php
9/10/2009 4:32 AM | # re: Testing Silverlight Applications
Hi,
Silvernium does not seem to work.I have looked through it's code and it seems to make JS calls to DOM to capture elements inside Silverlight.Please correct me if I am wrong,but Silverlight's functionality resides inside XAP file which cannot be directly accessed through JS.
Since Silvernium does not have feature to fetch XAP file and unzip/decode the same,it is not possible to automate SL controls using it.
8/26/2010 7:13 AM | # re: Testing Silverlight Applications
Please provide me some details about Open source Performance testing tools which supports silverlight applications
10/27/2010 11:27 PM | # re: Testing Silverlight Applications
Is it possible to automate the non-silverlight windows phone 7 apps(Zune Player, Camera) UI Testing using silverlight framework? Please respond.
3/6/2011 11:28 PM | # re: Testing Silverlight Applications
examples on unit testing using silverlight unit test framework?

 
Please add 7 and 1 and type the answer here:

DISCLAIMER:

The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.