Re: using Gtk2::TestHelper

On Jul 17, 2005, at 4:04 PM, Gábor Szabó wrote:

I just woke up from a long sleeping and would like to write some tests for my Perl Gtk application. I saw Gtk2::TestHelper but so far could not figure out how to use it. Can someone point me to an example please ?

Erm, nearly all of the tests under Gtk2/t/ use TestHelper, and there's POD in the module. Much of what i've written below duplicates that.

Gtk2::TestHelper is little more than a wrapper around Test::More. The basic purpose is to bring in commonly-used modules and initialize the main loop automatically. You can suppress that, if desired, of course. All import arguments are optional except "tests", which is the number of tests to be run.

   use Gtk2::TestHelper
       tests => 42,   # passed straight to Test::More
       noinit => 1,   # suppress call to Gtk2->init
# you can skip all tests in the module if gtk+ is not new enough:
       at_least_version => [ 2, 2, 0, $reason_for_skipping ],
       nowin32 => 1,  # don't try to run this file on windows

The module installs a key snooper which traps all keyboard input, so that if you are ttrying to type when the tests start popping up, your keystrokes don't break the test suite. This is rather important for long-running test suites. ;-)

A few other utilities include

- "TRUE" and "FALSE" are always imported from Glib
- Gtk2, Glib, and Data::Dumper are "use"d for you (since they're handy in tests) - run_main and ok_idle exist to allow you make your tests non- interactive a little more easily.

me: Need any help?
elysse, hugging the toilet: No thanks, i can puke just fine by myself.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]