When it comes to graphics "smoke" tests, one common approach is to capture the currently rendered image and then compare it bitwise or numerically to a human-sanctioned example. Sometimes two or four pixels are all you need to test, while other times you need a major chunk. Often, thanks to vendor/hardware/implementation issues, you should allow certain tolerances, such as RGB within 5 points of expected, or 99% of pixels are as expected.

If you design your tests carefully, you can have a "training" and a "smoking" mode. If there are no saved comparison results, it needs to "train" and save the current results as good. If there are comparison results already packaged with the tests, then the current code output needs to be checked against them in order to pass the smoke test. Testing isn't debugging: a third mode for debugging should be the only mode that requires user intervention.

Unfortunately, this means you probably need to write a comparitor that works well for you. I hope this is a call-to-action for you to make a nice PerlMagick or Image::* solution into a new Test::Images module with a looks_ok() for everyone. Take two images, subtract one from the other, and look for nonzero values as being unexpected differences.

--
[ e d @ h a l l e y . c c ]


In reply to Re: How to test Interactive/Graphical Modules by halley
in thread How to test Interactive/Graphical Modules by Molt

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.