line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Wait; |
2
|
|
|
|
|
|
|
# vim:syn=perl |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
58708
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
151
|
|
5
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
104
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use vars qw( $VERSION @ISA @EXPORT ); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
366
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
11
|
|
|
|
|
|
|
@EXPORT = qw( wait_stdin wait_x ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
18
|
use constant DEFAULT_WAIT_SECONDS => 10; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1226
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Test::Wait - Make tests wait for manual testing purposes. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Test::Wait is a tool for use in conjunction with test libraries such as Test::More for manual testing purposes. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
It was initially designed for use in Selenium based tests however it can be used in any test script. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Test::Wait provides a simple interface to pause test scripts at any given point, allowing you to inspect the test output or |
28
|
|
|
|
|
|
|
use the test-created data to run manual tests against the application in a browser or terminal. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Test::Wait; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
wait_stdin( [ 'i'm waiting for you to hit return' ] ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
wait_x( [ [ int seconds_to_wait ] [, "i'm waiting $seconds_to_wait seconds" ] ] ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 INTERFACE |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 wait_stdin( [ str message ] ) : nothing |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
wait ( for return key press ) before continuing a test. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
ignored if running under prove or make test. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub wait_stdin { |
51
|
2
|
|
|
2
|
1
|
5545
|
my $msg = shift; |
52
|
2
|
50
|
|
|
|
13
|
return if ( $ENV{HARNESS_ACTIVE} ); # don't wait if running under test harness eg; prove, make test |
53
|
0
|
|
|
|
|
0
|
my ( $pkg, $filename, $line ) = caller(); |
54
|
0
|
|
|
|
|
0
|
my $out_msg = 'I> ' . __PACKAGE__ . "::wait_stdin() - waiting at '$pkg' line '$line' ( $filename )"; |
55
|
0
|
0
|
|
|
|
0
|
$out_msg .= ": '$msg'" if ( defined($msg) ); |
56
|
0
|
|
|
|
|
0
|
print STDERR "$out_msg\n"; |
57
|
0
|
|
|
|
|
0
|
; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 wait_x( [ [ int seconds_to_wait ] [, str message ] ] ) : nothing |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
wait for $seconds_to_wait seconds before continuing a test. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
ignored if running under prove or make test. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub wait_x { |
69
|
5
|
|
|
5
|
1
|
2116
|
my ( $seconds, $msg ) = @_; |
70
|
5
|
50
|
|
|
|
21
|
return if ( $ENV{HARNESS_ACTIVE} ); # don't wait if running under test harness eg; prove, make test |
71
|
0
|
0
|
0
|
|
|
|
$seconds = DEFAULT_WAIT_SECONDS() if ( !defined($seconds) || $seconds !~ /^\d+$/ ); |
72
|
0
|
|
|
|
|
|
my ( $pkg, $filename, $line ) = caller(); |
73
|
0
|
|
|
|
|
|
my $out_msg = 'I> ' . __PACKAGE__ . "::wait_x() - waiting '$seconds' seconds at '$pkg' line '$line' ( $filename )"; |
74
|
0
|
0
|
|
|
|
|
$out_msg .= ": '$msg'" if ( defined($msg) ); |
75
|
0
|
|
|
|
|
|
print STDERR "$out_msg\n"; |
76
|
0
|
|
|
|
|
|
sleep( $seconds ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SEE ALSO |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Test::More, Test::Builder, Test::Simple, Selenium::Remote::Driver, Test::Harness |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHORS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Ben Hare |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 CREDITS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Inspired by code written by Chris Hutchinson . |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright (c) Ben Hare , 2014. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This program is free software. You can redistribute it and/or modify it under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See F |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |