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")

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.

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



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.

matt wrote re: Winforms (and WPF) Testing
on 10-15-2014 5:53 PM
matt crorkz wrote re: Winforms (and WPF) Testing
on 01-16-2015 5:45 PM

TR8PlX Thanks  for another informative blog. Where else could I get that type of info written in such an ideal way? I've a project that I am just now working on, and I've been on the look out for such info.

crrork wrote re: Winforms (and WPF) Testing
on 03-02-2015 10:53 PM

PLr396 I've recently started a web site, the info you provide on this web site has helped me tremendously. Thanks  for all of your time & work.

crork mattew wrote re: Winforms (and WPF) Testing
on 03-09-2015 7:57 PM

cZa6hU I'll immediately grab your rss as I can not find your e-mail subscription link or newsletter service. Do you've any? Please let me know so that I could subscribe. Thanks.

nick crorkzz wrote re: Winforms (and WPF) Testing
on 04-08-2015 12:00 PM

KR5Ywr Terrific work! This is the kind of info that should be shared across the web. Shame on the search engines for now not positioning this post higher! Come on over and discuss with my site . Thanks =)

find a free pron wrote re: Winforms (and WPF) Testing
on 10-14-2016 8:18 AM

h1TtfO This actually answered my own problem, thank an individual!

Barnypok wrote re: Winforms (and WPF) Testing
on 12-28-2016 5:49 PM
Barnypok wrote re: Winforms (and WPF) Testing
on 12-29-2016 5:30 AM
Barnypok wrote re: Winforms (and WPF) Testing
on 12-31-2016 8:52 PM
Barnypok wrote re: Winforms (and WPF) Testing
on 01-02-2017 12:24 PM
Barnypok wrote re: Winforms (and WPF) Testing
on 01-03-2017 7:10 PM

Add a Comment

Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)