Windows simple automated testing?

alanchinese

Regular
Joined
Jan 12, 2005
Messages
62
I want to write an automated testing tool in .Net.
For example, i have a winform including two textboxes (input) and one label (output):
1) open up the winform application
2) type numbers in two text boxes and click "calculate" button
3) verify the result in the label.

I know that my testing tool can open up the application (using process).
How do I achieve #2 and #3?
 
You would probably need to use various WinAPI calls to make this work. Firstly you would need to identify the relevant text boxes (FindWindowEx is probably the one to use), then attempt to set the text of the various controls (SendMessage is the one for this) and then you would need to simulate the button click (again IIRC SendMessage can also do this).

This is not going to be a trivial task however and it might be easier to see if you can find a tool that already provides this functionality.

Personally I would split the actual logic out from the form itself and have the button click event simply call methods defined in a separate class(es), this class(es) could then have a set of unit tests written which are far easier to automate and require no UI interaction.
 
Back
Top