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:44

OpenCTF is good for you.

Quote:

OpenCTF is a test framework add-on for Embarcadero Delphi® which performs automatic checks of all components in Forms (or DataModules).

It provides an easy way to build automatic quality checks for large projects where many components have to pass repeated tests.

Adding OpenCTF tests to a DUnit test suite requires only a few lines of code. Writing your own custom component tests needs only a few seconds.

OpenCTF is based on the DUnit open source test framework and extends it by specialized test classes and helper functions.

Please head here to download.

查看更多
贪生不怕死
3楼-- · 2019-03-27 23:51

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

查看更多
登录 后发表回答