views:

689

answers:

7

I'm building a test harness for my Delphi 2009 app. Testing the logic is fairly simple. Making sure the forms work properly is proving a bit more complicated. I'd like a way to simulate real user input, to open a form, make it think there's a user typing certain things and clicking in certain places, and make sure it reacts correctly. I'm sure there's a way to do this, I just don't know what it is. Does anyone know how to do it?

+1  A: 

well for .net there's NUnitForms for GUI testing a win application. don't know any open source for delphi though.

Test Complete can test delphi forms but it's not free.

Mladen Prajdic
A: 

Not exactly an answer to your question, but there is a very good page (IMHO of course) about GUI Architectures by Martin Fowler, featuring the "Humble View" architecture as the last entry, which is geared specifically towards test-driven software development. Worth looking into.

This will of course not help you with the task of testing whether all controls are wired correctly and handle all necessary events, but it should help to minimize the amount of GUI code that does need testing.

mghie
+1  A: 

There's 2 parts to this, firstly how do you automate the GUI, and secondly how do I then 'test' whether its working/not working.

Firtsly: To automate the GUI on windows try using AutoIT. Its a free tool for controlling windows interfaces, sending keyboard input events etc. http://www.autoitscript.com/autoit3/

Secondly: Testing is a big field, and I won't try and give you a whirlwind tour. But the mechanics of driving the GUI and testing the results could be handled using AutoIT's built in Basic like language or by using it in conjunction with a language like Ruby and TestUnit (rubys built-in unit testing framework).

Phoughton
+1  A: 

If there is nothing Deliphi-specic out there and you need a quick solution try some easy to learn scripting solutions like AutoIt. For a bit more sophisticated scripting, you might have a look on Scripted GUI Testing with Ruby.

But be aware, that you should not test too much functionality via the GUI, because such tests are very likely to break. If you end up with too much GUI testing you may need to rethink the design: Decouple logic from the GUI and test the logic directly with some xUnit framework.

Also have a look on a similar question about windows forms test automation.

Theo Lenndorff
+6  A: 

DUnit has GUITesting.pas whicih extends testing so you can send clicks, keys and text to controls on form, but that is about it.

Last year there where mentions of Zombie GUI testing framework that was used internaly by CodeGear developers, but nothing since Steve left for Falafel.

dmajkic
Thanks! That's just what I'm looking for.
Mason Wheeler
I wouldn't rely on anything CodeGear uses for testing. If it worked there would be far less bugs in the UI and the code itself :)
Boris
+5  A: 

TestComplete is a good choice. Another commercial option for GUI testing is SmarteScript:

Bruce McGee
+1  A: 

It seems like DUnit has some gui-testing functionality: delphiextreme.com

Vegar