First of all those who know me will be wondering what on earth I am doing writing testing articles. Well don't worry folks I haven't gone over to the other side. As I write this I am working for Lab49 on site at a major bank in the City of London and the project is supposed to be agile, but in my view a key component of agile development was missing, automated testing. Sure we have thousands of unit tests and most of them are run as part of a continuous integration build on each commit of code, but there were no automated integration or regression tests. Actually that is not strictly true, one senior member of the test team was using White to write some automated tests but he wasn't getting very far due to time constraints and when he did have the time he wasn't really up to speed with C# so wasn't as productive as he would have liked. So when I spoke up and suggested using the WebAii UI Automation Framework from Telerik (who had recently merged with the original vendor Art Of Test) I pretty much talked myself into the job of proving it would work and educating the masses so more C# coders could get involved.
After the best part of a month I have put together 100+ complex scenarios that provide a good regression suite for the basic functionality of the Silverlight application we are building and have a good grounding on how to use WebAii to test Silverlight. It wasn't an easy journey because there isn't a lot of documentation out there and what I found is pretty basic. There is a lot of info in forums but after my journey I figured I was well placed to write a series of articles that will hopefully help others and make their journey a little easier.
So without further rambling let's get on with it. In this first article in the series I am going to talk you through the tools you will need to install before writing any tests.
What you will need
If you want to try any of this out or use the sample code I will provide with each article you will need a few things installed first. This section will help you get those in place and get you ready to go.
I am using VS 2010 Pro but the code should work with VS 2010 Express. If you haven't upgraded yet the code should work with VS 2008 but you will need to manually downgrade the solution and project files I provide or copy them into a new solution you create.
WebAii UI Automation Framework
Download this from http://www.telerik.com/community/download-free-products.aspx
You need to install this on your development machine but also on any machine that will run the tests. This is because WebAii relies on browser extensions that must be properly installed and registered. This can be a bit of pain because many people don't like installing components on build servers or test clients but believe me it is the best option. I spent some time trying to avoid running the installer and it wasn't worth the effort in the end.
I am using NUnit because it does data driven testing much better than the MS Test tools built in to VS 2010, but it shouldn't be difficult to migrate some of the code across if you need to use MS Test. If time allows I will try to provide samples for both.
Or any other tool that can snoop the visual tree of a Silverlight application. I recommend Silverlight Spy though, it does a lot more than we need and should be in the toolbox of every Silverlight developer, you can run it in trial mode to work through these samples. You can get Silverlight Spy at http://firstfloorsoftware.com/silverlightspy/download-silverlight-spy/
What are we going to test
Microsoft provide a reference Silverlight application "Microsoft Health Common User Interface", in particular we are going to use the Primary Care Demonstrator application. The application is complex and uses some complex controls so it will allow me to demonstrate dealing with this type of application without having to create or contrive one. The application is publicly available so you will be able to run the sample tests I provide without any problem. Also there are some samples in the WebAii download that reference the MS CUI application so the familiarity you gain through this series will hopeful make these more useful to you. Before moving on to the next article I recommend spending a little time browsing the MS CUI at http://pjd.mscui.net/PrimaryCare.htm.
Start by clicking on the Show Guide button in the top right corner, this will overlay the whole screen with guidance that will help you become familiar with the application.
Articles in this series
Setting Up a WebAii Test Project with NUnit
WebAii Test Settings and Configuration
Finding Elements with WebAii
Wrapping up with WebAii