GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Tk(3) User Contributed Perl Documentation Test::Tk(3)

Test::Tk - Testing Tk widgets.

 use Test::More tests => 5;
 use Test::Tk;
 
 BEGIN { use_ok('Tk::MyWidget') };
 
 createapp(@options);
 
 my $widget;
 if (defined $app) {
    $widget = $app->MyWidget->pack;
 }
 
 push @tests,
    [sub { return defined $widget }, 1, 'Created MyWidget'],
    [sub { return 1 }, 1, 'A demo test'],
 ;
 
 starttesting;

This module aims to assist in the testing of Perl/Tk widgets.

createapp creates a MainWindow widget and places it in the variable $app. It sets a timer with delay $delay to start the internal test routine.

starttesting launches the main loop and sets a timer with delay $delay to start the internal test routine.

When testing is done the MainWindow is destroyed and the test script continues.

You can set a command line parameter show to test command on the command line. eg perl -Mblib t/My-Test.t show. The application will not terminate so you can visually inspect it.

It will perform two tests. You need to account for these when you set your number of tests.

If you are not on Windows and no XServer is running, all tests will be skipped.

$app
Holds the reference to the MainWindow object. If you are not on Windows and no XServer is running, the MainWindow will not be created and $app remains undefined. Do not change this variable.
$delay
Default value 100. The delay time between creating the test app and start of the testing. You may want to increase this value in case all tests succeed but your test program still throws an error.
$mwclass
Default value Tk::MainWindow. You can set it to a derived class.
$quitdelays
Default value 200. This is the delay set between the termination of tests and the desctruction of the main widow. If your desktop goes bonkers while testing, you main want to increase this value. But I think you're good.
@tests
Each element of @tests should contain a list of three elements.
The sub should return the expected value for the test to succeed. It should always return something in scalar context.
This can be a simple scalar but also the reference to a list or a hash. You may even specify a complexer data structure.
A brief description of the test so you know which test passed or failed.
$show
By default 0. Is set when the show option is given at the command line. You can overwrite this by setting or clearing this yourself.
Creates the MainWindow object and tests if successfull. Places the object in B>$app>.
Depricated, use Test::Deep or Data::Compare.
Depricated, use Test::Deep or Data::Compare.
Pauses the app for $miliseconds, allowing background processes to finish.
Launches the main loop and sets a timer with delay $delay to start the internal test routine.
Quickly set up accessor tests. Just to be clear, an accessor is something like this.

 sub Value {
    my $self = shift;
    $self->{VALUE} = shift if @_;
    return $self->{VALUE}
 }
    

Test::More Test::Deep

Hans Jeuken, <hanje at cpan dot org@>

This should also work for Tcl::pTk widgets. However, the testing of this module during install is done with Tk. So this is set as a prerequisite. A duplicate module with slightly different defaults for Tcl::pTk is thinkable.

Copyright (C) 2023 - 2024 by Hans Jeuken

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2024-07-10 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.