How do I fake input for form testing?

2019-03-27 23:24发布

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?

8条回答
贪生不怕死
2楼-- · 2019-03-27 23:24

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

查看更多
时光不老,我们不散
3楼-- · 2019-03-27 23:28

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.

查看更多
Emotional °昔
4楼-- · 2019-03-27 23:29

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

查看更多
贼婆χ
5楼-- · 2019-03-27 23:30

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.

查看更多
混吃等死
6楼-- · 2019-03-27 23:32

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.

查看更多
Root(大扎)
7楼-- · 2019-03-27 23:34

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.

查看更多
登录 后发表回答