Revision 111276a1
Von Thomas Kasulke vor etwa 17 Jahren hinzugefügt
t/selenium/AllTests.t | ||
---|---|---|
1 | 1 |
#===================================================================== |
2 | 2 |
# LX-Office ERP |
3 |
# Copyright (C) 2006 |
|
3 |
# Copyright (C) 2006/2007
|
|
4 | 4 |
# Web http://www.lx-office.org |
5 | 5 |
# |
6 | 6 |
#===================================================================== |
7 | 7 |
# |
8 |
# Author: Udo Spallek |
|
9 |
# Email: udono@gmx.net |
|
8 |
# Author: Udo Spallek, Thomas Kasulke
|
|
9 |
# Email: udono@gmx.net, tkasulke@linet-services.de
|
|
10 | 10 |
# |
11 | 11 |
# This program is free software; you can redistribute it and/or modify |
12 | 12 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
30 | 30 |
# |
31 | 31 |
####################################################################### |
32 | 32 |
no strict; |
33 |
push @INC, ['/t/selenium']; |
|
33 |
push @INC, ['/t/selenium', \&init_server];
|
|
34 | 34 |
use vars qw( $lxdebug $lxtest $sel ); |
35 | 35 |
use strict; |
36 | 36 |
use Carp; |
37 | 37 |
|
38 | 38 |
use Test::WWW::Selenium; |
39 |
use Test::More; |
|
39 |
use Test::More qw(no_plan);
|
|
40 | 40 |
use IO::Socket; |
41 | 41 |
|
42 |
eval { require('t/lxtest.conf'); }; |
|
42 |
|
|
43 |
if(-f "/tmp/lxtest-temp.conf") { |
|
44 |
eval { require('/tmp/lxtest-temp.conf'); }; |
|
45 |
} |
|
46 |
else { |
|
47 |
eval { require('t/lxtest.conf'); }; |
|
48 |
} |
|
43 | 49 |
if ($@) { |
44 | 50 |
diag("No test configuration found in t/lxtest.conf.\n |
45 | 51 |
Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n"); |
46 | 52 |
exit 0; |
47 |
};
|
|
53 |
} |
|
48 | 54 |
|
49 | 55 |
sub server_is_running { |
50 | 56 |
return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost}, |
51 | 57 |
PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport}, |
52 | 58 |
); |
53 | 59 |
} |
54 |
if (server_is_running) { |
|
55 |
plan tests => 204; # Need to be cutomized |
|
56 |
} |
|
57 |
else { |
|
58 |
plan skip_all => "No selenium server found! " |
|
59 |
."Maybe you forgot to start it or " |
|
60 |
."the preferences in t/lxtest.conf doesen't fit to your system"; |
|
61 |
exit 0; |
|
62 |
} |
|
63 |
|
|
64 |
diag('Pretests and initialisation'); |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
$lxtest->{test_id} = time; # create individual ids by unixtime |
|
69 |
$lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id}; |
|
70 |
$lxtest->{testuserpasswd} = $lxtest->{test_id}; |
|
71 |
$lxtest->{db} = $lxtest->{db} . $lxtest->{test_id}; |
|
72 |
|
|
73 |
ok(defined $lxtest->{rpw}, "Get root password"); |
|
74 | 60 |
|
75 |
ok(defined $lxtest->{dbhost}, "found dbhost in config"); |
|
76 |
ok(defined $lxtest->{dbport}, "found dbport in config"); |
|
77 |
ok(defined $lxtest->{dbuser}, "found dbuser in config"); |
|
78 |
ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config"); |
|
79 |
|
|
80 |
$lxtest->{lxadmin_url} = $lxtest->{lxbaseurl} . "admin.pl"; |
|
81 |
$lxtest->{lxadmin_with_get} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; |
|
82 |
$lxtest->{lxadmin} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; |
|
61 |
# if (server_is_running) { |
|
62 |
# plan tests => 200; # Need to be cutomized |
|
63 |
# } |
|
64 |
sub init_server { |
|
65 |
if(!server_is_running) { |
|
66 |
print "No selenium server found! " |
|
67 |
."Maybe you forgot to start it or " |
|
68 |
."the preferences in t/lxtest.conf doesen't fit to your system"; |
|
69 |
exit 0; |
|
70 |
} |
|
83 | 71 |
|
72 |
diag('Pretests and initialisation'); |
|
84 | 73 |
|
85 | 74 |
|
86 | 75 |
|
87 |
eval { $sel = Test::WWW::Selenium->new( |
|
88 |
host => $lxtest->{seleniumhost}, |
|
89 |
port => $lxtest->{seleniumport}, |
|
90 |
browser => $lxtest->{seleniumbrowser}, |
|
91 |
browser_url => $lxtest->{lxadmin}, |
|
92 |
auto_stop => '0', |
|
93 |
); |
|
94 |
}; |
|
95 |
if ($@) { |
|
96 |
diag("No Selenium Server running, or wrong preferences\n\n"); |
|
97 |
exit 0; |
|
98 |
} |
|
99 |
|
|
100 |
ok(defined $sel, 'Creating Selenium Object'); |
|
76 |
$lxtest->{test_id} = time; # create individual ids by unixtime |
|
77 |
$lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id}; |
|
78 |
$lxtest->{testuserpasswd} = $lxtest->{test_id}; |
|
79 |
$lxtest->{db} = $lxtest->{db} . $lxtest->{test_id}; |
|
101 | 80 |
|
102 |
diag('Starting Selenium tests...'); |
|
103 |
|
|
104 |
opendir(SCRIPTS, 't/selenium/testscripts'); |
|
105 |
my @testscripts = sort readdir(SCRIPTS); |
|
81 |
ok(defined $lxtest->{rpw}, "Get root password"); |
|
106 | 82 |
|
107 |
foreach my $script (@testscripts){ |
|
108 |
my $file = "t/selenium/testscripts/" . $script; |
|
109 |
require_ok($file) if ( $script =~ /^\d\d\d.*\.t$/ ); |
|
83 |
ok(defined $lxtest->{dbhost}, "found dbhost in config"); |
|
84 |
ok(defined $lxtest->{dbport}, "found dbport in config"); |
|
85 |
ok(defined $lxtest->{dbuser}, "found dbuser in config"); |
|
86 |
ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config"); |
|
87 |
|
|
88 |
$lxtest->{lxadmin_url} = $lxtest->{lxbaseurl} . "admin.pl"; |
|
89 |
$lxtest->{lxadmin_with_get} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; |
|
90 |
$lxtest->{lxadmin} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; |
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
eval { $sel = Test::WWW::Selenium->new( |
|
96 |
host => $lxtest->{seleniumhost}, |
|
97 |
port => $lxtest->{seleniumport}, |
|
98 |
browser => $lxtest->{seleniumbrowser}, |
|
99 |
browser_url => $lxtest->{lxadmin}, |
|
100 |
auto_stop => '0', |
|
101 |
); |
|
102 |
}; |
|
103 |
if ($@) { |
|
104 |
diag("No Selenium Server running, or wrong preferences\n\n"); |
|
105 |
exit 0; |
|
106 |
} |
|
107 |
|
|
108 |
ok(defined $sel, 'Creating Selenium Object'); |
|
109 |
|
|
110 |
diag('Starting Selenium tests...'); |
|
111 |
|
|
112 |
foreach my $scriptdir (@_) { |
|
113 |
opendir(SCRIPTS, 't/selenium/testscripts/' . $scriptdir); |
|
114 |
foreach (sort readdir(SCRIPTS)) { |
|
115 |
require_ok("t/selenium/testscripts/". $scriptdir . "/" . $_) if ( $_ =~ /^\w\d\d\d.*\.t$/); |
|
116 |
} |
|
117 |
closedir(SCRIPTS); |
|
118 |
} |
|
119 |
$sel->stop(); |
|
110 | 120 |
} |
111 |
exit 1; |
|
112 |
|
|
113 |
$sel=''; # Destroy selenium object |
|
114 |
|
|
115 |
exit 1; |
|
116 |
|
|
121 |
|
|
122 |
1; |
Auch abrufbar als: Unified diff
Angepasst an die "neue" Testumgebung