Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...