Testing GUIs is one of the most challenging tasks a tester can undertake. Automated testing of GUIs is an order of magnitude harder. Your dealing with user logic, rather than program logic, and no matter how twisted a programs logic is, you can at least inspect it. Users are not so easily tied down, and they are apt to see your GUI in completely different ways to you.

About the only reasonable way to automate GUI tests is to use some sort of external record and playback mechanism. (See Win32::GuiTest if your running on that platform. I have no knowledge of Prima).

Attempting to emulate the user from within the script under test will cause you to have to do things like duplicating state normally mantained within, and queried from, the GUI object elements themselves, and replicate these into alternate storage (as you mentioned).

This is filled with dire consequences. You're duplicating state and it will enevitably get out of sync. You're adding complexity within your application and completely changing the dynamics of the code. If you only use the duplicated state for testing and query the data from the GUI objects for use, then you are not testing your real code.

A mouse/keystroke recorder that allows you to replay previously recorded, manually-driven test sessions and then compare the states, preferable at each intermediate step as well as the final state--is the only reasonably successful method I have seen.

The recording of mouse actions should be recorded relative to the application window(s), not in absolute screen coordinates to avoid differences caused by where the system displays the windows.

The state comparison should be in terms of text displayed in the controls, the state (highlighted, greyed etc.) and recorded in a manner that allows it to be viewed and edited manually.

Not as a binary file. And not as bitwise comparisons of bitmaps of window or screen captures. Screens vary in size. Windows are usually movable and sizeable. Users can configure their desktops with different colours, fonts and reposition/hide screen elements like toolbars.

That's just a description of the best way (I know of) to do your testing, and some of the pitfalls to watch out for. It doesn't really help you with your quest to write tests, but maybe it will be helpful.

Good luck.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Testing a GUI application by BrowserUk
in thread Testing a GUI application by carcassonne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.