Those of us who primarily work on web projects have a fairly good idea of what's available for automating UI testing of web applications; Selenium and WatiN, for instance. At Headspring, we take this up a level by isolating our UI testing code from the nuts and bolts of the page HTML, as well as the equally troublesome nuts and bolts of these UI testing tools. You can take a look at how we do things by taking a look at MvcContrib, which has a testing framework and Code Camp Server, which has some example usage.
A code snippet from Code Camp Server to illustrate:
Form<logininputproxy>("/login/login/index") // url
.Input(m => m.Username, "admin")
.Input(m => m.Password, "password")
It's great to have these kind of tools for the web, but what if we end up working on a Webforms or WPF project? It turns out there's a project on CodePlex called white, and it does for winforms and WPF what WatiN does for the web. Crank it up, and just like WatiN pops up a browser and starts interacting with your web app for you, white will click around and enter text into your winform app. However, working with white as-is means tightly coupling our testing code to the tool-which we want to avoid just as much with winforms as we did with web testing. Not to mention, if white is wrapped well enough that working with it is pretty much the same as working with WatiN, that's one less difference to remember-meaning more focus on solving problems, and less on figuring out how to work yet-another-tool. We're only starting out, but here's an example of how working with it; with any luck, it should look a bit like the code snippet above:
Form<testform2input>("White Hello World") // form name
.Input(x => x.PersonName, "Bart Simpson")
Winforms aren't exactly like the web, and likely the metaphors age going to have to adapt to avoid strange impedance mismatches- so it's probably not going to be seamless moving from one to the other. However, if it's similar, taking into account these differences, then when switching to testing a winforms project, it might seem...about the way you'd expect.
This is very, very young, but the starter code for this wrap of white is available at my CodePlex repository.
03-24-2010 2:33 PM