Testing the GUI is still a terrible task. There are tools to help you track and play interactive input. I used some of these APIs (code stolen from Perl) to inject keystroke events into another application (to open a new URL in firefox without opening a new tab). But this is not very good for testing.
Additional tools cost several kilograms of dollars and come with external script languages, and usability reports are shared. http://en.wikipedia.org/wiki/List_of_GUI_testing_tools
The GUI has two different areas. One of them fills dialogs with user parameters, and the other is testing the model / view.
The first can be easily solved with a few coding rules. For example, dialog boxes do not change anything, but they take and return classes with all parameters. In this case, you can simply replace the dialog code with your own code. This is the easy part. In my code dialogs, change the settings of the ini file, and then just notify the model with a few tips what has changed.
Testing views and models is much more complicated. If itβs a drawing, you can try using the WM_PRINT message to capture the view, and then run your test and compare its result with the previous captured data. If the bitmaps are the same, the test passes. I have never seen this technique used in the real world, with the exception of one toolkit, where he used it to verify the exact drawing of pixels on multiple platforms.
Next, a model based on interactive code is tested. As mentioned earlier, key events are easier to emulate than most translate directly to a separate command processing code anyway, so you just check the commands, not the key event handler. Selecting and manipulating the mouse, for example, selecting an object on a canvas, is much more complicated. Or use one of these testing tools that promise to capture and replay mouse actions or pray.
Depending on your own code base, there are many different ways if you are abstract from MFC good enough to use mock GUI objects instead of real MFC windows. And if you have already embedded a script language that can help you check things, etc. Sorry there is no simple template. This must be decided on a case-by-case basis.
My own experience is that I donβt like unit testing GUI and unit testing. This is often not worth the time. I use Eiffel and Design by Contract (which means a lot of claims for approval) and conducts extensive beta tests with clients and allows clients to find the remaining errors. In most cases, most errors are erratic usability errors.