views:

1485

answers:

8

We are working on a large project with a measure of new/modified GUI functionality. We've found in the past that we often introduced new problems in related code when adding new functionality.

We have non-technical users perform testing, but they often miss parts and allow bugs to slip through.

My question: Are there any best practices for organizing the UI testing of a WinForms project? Is there any way to automate it?

Thanks!

+15  A: 

There are GUI testing tools that will click buttons and stuff for you but they're pretty fragile in my experience.

The best thing to do is to keep your UI layer as thin as possible. Your event handler classes should optimally be only one or two lines that call out to other more testable classes. That way you can test your business logic in unit tests without having to actually do a button click.

jodonnell
Anyway, author needs a solution, not objections only...
Budda
A: 

I can't really help with organization or best practices, but an NUnit extension appears to be available for forms testing, NUnitForms.

Anthony Mastrean
+1  A: 

The following book is an introduction to the subject. There are as many ways as there are developers out there..

http://pragprog.com/titles/idgtr/scripted-gui-testing-with-ruby

khebbie
+4  A: 

You can automate GUI testing using White framework.

Also consider using TDD friendly design, i.e. use MVP/MVC pattern.

I would highly recommend you to read documentation from Microsoft patterns&practies teams.

Especially have a look at the Composite UI application block and CompositeWPF.

These projects specifically designed to give you best practices in GUI apps development including test driven UI.

aku
"Also consider using TDD friendly design, i.e. use MVP/MVC pattern." Correct me if I am wrong, but wouldn't this be a " **Test** friendly design". I think that TDD suggests much more than just testing..
sixtyfootersdude
+4  A: 

Keep the GUI layer as thin as possible. Michael Feathers article, The Humble Dialog Box, is a classic. Also check out Martin Fowler's Passive View. I have also heard that the "automatic button clickers" are fragile, and that it's easy to spend more time maintaining the test than you spend maintaining the code.

Brian Stewart
A: 

There are many tools and libraries available that can automate WinForms testing, ranging from open source solutions like White to the expensive commercial solutions such as HP QuickTest Pro. There is also the UIAutomation namespace in .NET if you want to roll your own automation framework. But the real cost of automation is in the time and specialised skills it requires to implement. Maintainability is also one of the most important aspects of automated test design; you dont want to expend excessive resource keeping the automation assets current with your application. There are also lots of factors influencing the decision to automate which will be specific to your specific application and organisation.

Your best bet will be to do some more research on the subject and check out some of the specialised testing sites such as http://www.sqaforums.com.

Sam Warwick
+1  A: 

I found this quick and dirty way to test web page layouts in various browsers. It's called browsershots.org. Our client requires support in 5 browsers right now and that takes about a week for full regression testing. This service will deliver screenshots of some 70+ browsers and versions. I print them out and hold up the pages to the light. If they don't line up, there must be a layout problem.

Dr. UNIX
A: 

I used a trial download similar to this product (http://www.tethyssolutions.com/product.htm) and this product (http://www.mjtnet.com/macro_scheduler.htm) years ago and I was happy with the results. These are pretty cheap solutions and some of these macro recorder products can actually be used for automated testing.

Kurt W. Leucht