The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Automate testing of a GUI control?

Can you give me any pointers to tips or tools towards automating the testing of a .NET GUI control (a text editor, derived from System.Windows.Forms.Control)?

A typical test that I'd want to automate is:

* Instantiate control and give it a document to display - verify that document is rendered, with line-breaks in the right place

* Scroll the document - verify that it scrolls as expected

* Mouse click - verify that the insertion caret is at the expected location in the document

* Select a block of text using the mouse (mouse down, mouse move, mouse up) - verify that the expected block of text is selected

* Press the <Del> key - verify that the selected block of text is deleted

* Press <x> to insert an 'x' - verify that an 'x' is inserted into the document and that the corresponding line is repainted

* Press <x> multiple times to insert an "xxxxxxxxxxx" - verify that the line as well as the rest of the paragraph below it is repainted to account for the new word-wrap location.

I'd like:

* Fairly easy to create a new test case
* Easy to maintain test cases (never want to have to rewrite all existing test cases after refactoring the implemenation)
* Easy to run all test cases

As a trade-off, I'd be willing to do the 'verification' by inspecting/asserting the contents of debug log messages created by the control, instead of by 'visually' inspecting the screen bitmap.

Would a problem with using NUnit for this be that it's synchronous? I don't know how to keep the control's message pump running while an Nunit test case is running . What's the .NET equivalent of the GetMessage/DispatchMessage loop? Would it work to insert "while GetMessage(form.hWnd,&msg) DispatchMessage(&msg);" using PInvoke between every line of an Nunit test case?

I'm thinking this must be a well-known problem with well-known solutions, but I've never before tried to automate the testing of a GUI control.
Christopher Wells Send private email
Tuesday, February 06, 2007
from a recent bos thread.

"automated software testing using mjnet macro scheduler or testcomplete from automatedQA"

Also search bos for "Automate testing"
Tuesday, February 06, 2007
An interesting talk on the topic (some product specific things, but a lot of general principles too) is at
Brian Mitchell
Tuesday, February 06, 2007
> automated software testing using mjnet macro scheduler or testcomplete from automatedQA

These automate e.g. clicking various identifiable windows (such as buttons) on a form; and, reading standard properties like "enabled" or "text" from standard GUI widgets such as "checkbox" or "editbox".

I'm not asking about how to test a form and/or standard GUI objects: I want to test a custom control.
Christopher Wells Send private email
Tuesday, February 06, 2007
I've used Microsoft Act before which worked well.
Justin Send private email
Wednesday, February 07, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz