Winforms (and WPF) Testing

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")
                       .Submit();

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")
                .Submit();

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.


Posted 03-24-2010 2:33 PM by Anne Epstein

[Advertisement]

Comments

Sean Kearon wrote re: Winforms (and WPF) Testing
on 03-25-2010 8:55 AM

Winform apps are the poor cousin when it comes to UI testing, so this is some very worthwhile work you've done.  Thanks for the post.

DotNET News wrote DotNET News
on 03-25-2010 2:40 PM

DotNET News

Lucas Berger wrote re: Winforms (and WPF) Testing
on 08-09-2010 1:13 PM

I agree with Sean.  This is a very worthwhile post and the associated sample project was especially helpful.  Thank you!

Kostas wrote re: Winforms (and WPF) Testing
on 10-08-2010 7:32 AM

Hi, glad to visit you..<

crorkservice wrote re: Winforms (and WPF) Testing
on 07-18-2014 1:37 PM

XRkviH I am so grateful for your blog post.Thanks Again. Want more.

matzcrorkz wrote re: Winforms (and WPF) Testing
on 08-06-2014 5:53 AM

fdxUaX Wow, great article post.Much thanks again. Much obliged.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)