how to test winforms applications
Our.NET application is based on Winforms. The application controls different instruments and most of the behavior is nicely stubbed to enable unit testing. One thing we come across many times is problems caused by (wrongly using) the GUI. Wrongly handling a controls event or accidentally selecting an item in a listbox that is not there. This would be the example I would like to have some help with:
We have a gridcontrol that users use to select an item. When the user selects a certain item, this should update the 'activeItem' in our model. Now we found开发者_JAVA技巧 out that there was a bug in here, since when the user used a shortcut to select the last item in the gridcontrol, it did not update the control. Of course this is caused by errors we make in the programming, but how could I test this GUI behavior. So that we are sure, if somebody changes the gridcontrol, it still works as expected. Could this be done with normal Unit Testing, or am I getting it completely wrong?
Thanks,
Erik
In our software we have some unit tests which instantiate the forms and perform actions on them and then then check the state of the model if it conforms to the expectations. So in that regards - yes you can do it with unit tests. However we also found it's easy to break those tests by changing the UI around and can involve quite a bit of maintenance. There are automated test frameworks around there which can make your life easier. I have had a brief look at White and NUnitForms but haven't done much with them yet. Feel free to share your experience.
As far as I've seen it this part of testing is usually handled by automated testing software such as TestComplete or QTP. Most automating softwares allow you to record a set of actions which should be done, then specify the expectations which will be checked when actions will be replayed.
But learning such a software is usually a separate skill than either developing a production code or manual software testing so in our company for example we have separate positions for automation QA engineers.
精彩评论