1 #=====================================================================
3 # Copyright (C) 2006/2007
4 # Web http://www.lx-office.org
6 #=====================================================================
8 # Author: Udo Spallek, Thomas Kasulke
9 # Email: udono@gmx.net, tkasulke@linet-services.de
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #======================================================================
26 # For collecting all the tests in nice Test::Harness environment.
27 # Study the README for Selenium Installation and testing process
30 # against the unstable release
31 #======================================================================
33 use warnings FATAL => 'all';
38 my %tests = ("all" => 't/selenium/TestAllTests.t',
39 "system" => 't/selenium/TestSystem.t',
40 "selling" => 't/selenium/TestSelling.t',
41 "masterdata" => 't/selenium/TestMasterData.t',
42 "testbed" => 't/selenium/TestCreateTestbed.t',
43 "admin" => 't/selenium/TestAdmin.t',
44 "accounting" => 't/selenium/TestAccounting.t',
45 "payments" => 't/selenium/TestPayments.t',
46 "printing" => 't/selenium/TestPrinting.t',
47 "programm" => 't/selenium/TestProgramm.t',
48 "reports" => 't/selenium/TestReports.t' );
54 eval { require('t/lxtest.conf'); };
55 my %lxtest = %{ $lxtest } if ($lxtest);
59 print "\n$0 --- creates testscenarios while using Selenium testcases for Lx-Office\n";
60 printf "\t\tusage: perl [PERLOPTIONS] $0 [--help] [OPTIONS] [ARGUMENTS]\n\t\t%s\n", "\xAF" x 6;
61 print "\t\t --help\t\tshow this usage\n\n";
62 printf "\t\toptions:\n\t\t%s\n", "\xAF" x 8;
63 print "\t\t -masterdata\tonly runs testscripts for \"masterdata\"\n";
64 print "\t\t -accounting\tonly runs testscripts for \"accounting\"\n";
65 print "\t\t -system\tonly runs testscripts for \"system\"\n";
66 print "\t\t -payments\tonly runs testscripts for \"payments\"\n";
67 print "\t\t -programm\tonly runs testscripts for \"programm\"\n";
68 print "\t\t -printing\tonly runs testscripts for \"printing\"\n";
69 print "\t\t -reports\tonly runs testscripts for \"reports\"\n";
70 print "\t\t -selling\tonly runs testscripts for \"selling\"\n";
71 print "\t\t -purchase\tonly runs testscripts for \"purchase\"\n";
72 print "\t\t -admin\tonly runs testscripts for \"administration\"\n";
73 print "\t\t -testbed\tcreates a standardized test database\n";
74 print "\t\t -nodb\t\tdoesn't create a db! Only use with \n\t\t\t\t--username, --userpasswd, --dbname, --dbport, --dbhost, --dbuser, --dbpasswd, --rootpasswd arguments!\n";
75 print "\t\t -showtests\tfinally shows all tests available only\n";
76 print "\t\t -singletest\toption flag for using single tests shown in \"-showtests\"\n";
77 printf "\n\t\targuments:\n\t\t%s\n","\xAF" x 10;
78 print "\t\t --test=\tname of Test shown in showtests seperated by , (Only joined by -singletest)\n";
79 print "\t\t --username=\tuser login name\n";
80 print "\t\t --userpasswd=\tuser login password\n";
81 print "\t\t --dbname=\tname of used db (leave empty whether dbname is seleniumtestdatabase)\n";
82 print "\t\t --dbport=\tport of used db (leave empty whether port is 5432)\n";
83 print "\t\t --dbhost=\thost of used db (leave empty whether host is localhost [127.0.0.1])\n";
84 print "\t\t --dbuser=\tdb username (leave empty whether name is postgres)\n";
85 print "\t\t --dbpasswd=\tthe password for used db (leave empty while none)\n";
86 print "\t\t --rootpasswd=\troot password for admin.pl login\n";
87 printf "\t\t NOTE: Configuration in lxtest.conf will be temporaly overwritten by using this arguments!\n\t\t %s\n", "\xAF" x 6;
95 if ( /^--help$/ ) { usage; last }
96 elsif ( /^-showtests$/) { $showtests = 1; shift; next }
97 elsif ( /^-nodb$/ ) { $nodb = 1; shift; next }
98 elsif ( /^-(masterdata)$/ ) { push @totest, $1; shift; next }
99 elsif ( /^-(system)$/ ) { push @totest, $1; shift; next }
100 elsif ( /^-(selling)$/ ) { push @totest, $1; shift; next }
101 elsif ( /^-(purchase)$/ ) { push @totest, $1; shift; next }
102 elsif ( /^-(testbed)$/ ) { push @totest, $1; shift; next }
103 elsif ( /^-(payments)$/ ) { push @totest, $1; shift; next }
104 elsif ( /^-(admin)$/ ) { push @totest, $1; shift; next }
105 elsif ( /^-(printing)$/ ) { push @totest, $1; shift; next }
106 elsif ( /^-(reports)$/ ) { push @totest, $1; shift; next }
107 elsif ( /^-(accounting)$/ ) { push @totest, $1; shift; next }
108 elsif ( /^-(purchase)$/ ) { push @totest, $1; shift; next }
109 elsif ( /^-(programm)$/ ) { push @totest, $1; shift; next }
110 elsif ( /^-singletest$/ ) { $singletest = 1; shift; next }
111 elsif ( /^--username=(.*)$/ ) { $lxtest{testuserlogin} = $1; shift; next }
112 elsif ( /^--userpasswd=(.*)$/ ) { $lxtest{testuserpasswd} = $1; shift; next }
113 elsif ( /^--dbname=(.*)$/ ) { $lxtest{db} = $1; shift; next }
114 elsif ( /^--dbport=(.*)$/ ) { $lxtest{dbport} = $1; shift; next }
115 elsif ( /^--dbhost=(.*)$/ ) { $lxtest{dbhost} = $1; shift; next }
116 elsif ( /^--dbuser=(.*)$/ ) { $lxtest{dbuser} = $1; shift; next }
117 elsif ( /^--dbpasswd=(.*)$/ ) { $lxtest{dbpasswd} = $1; shift; next }
118 elsif ( /^--rootpasswd=(.*)$/ ) { $lxtest{rpw} = $1; shift; next }
119 elsif ( /^--test=(.*)$/ ) { foreach (split(/\,/, $1)) { push @totest, $_; } shift; next }
120 elsif ( /^([A-Z].*)$/ ) { push @totest, shift; next }
122 print STDERR "$0: ERROR: unrecognized option '$_' ?\n";
127 unlink("/tmp/lxtest-temp.conf") if (-f "/tmp/lxtest-temp.conf");
128 open TEMPCONF, "+>/tmp/lxtest-temp.conf";
129 print TEMPCONF '$lxtest = {'."\n";
130 foreach (keys(%lxtest)) {
131 print TEMPCONF '"' . $_ . '" => "' . $lxtest{$_} . "\",\n";
136 if($singletest || $showtests) {
137 my $testscriptdir = 't/selenium/testscripts/';
138 opendir(ROOT, $testscriptdir);
139 foreach my $dir ( readdir( ROOT ) ) {
140 if(-d $testscriptdir . $dir && $dir ne "begin" && $dir ne "end" && $dir ne "..") {
141 opendir(DIR, $testscriptdir . $dir . "/begin");
142 foreach ( readdir(DIR) ) {
143 $tests{ substr ( substr( $_, 4 ), 0, -2 ) } = $testscriptdir . ($dir eq "." ? "" : $dir . "/") . "begin/" . $_ if ( $_ =~ /^\w\d\d\d.*\.t$/ );
146 opendir(DIR, $testscriptdir . $dir . "/end");
147 foreach (readdir(DIR)) {
148 $tests{ substr ( substr( $_, 4 ), 0, -2 ) } = $testscriptdir . ($dir eq "." ? "" : $dir . "/") . "end/" . $_ if ( $_ =~ /^\w\d\d\d.*\.t$/ );
155 push @totest, "all" if(!$totest[0]);
172 printf "\tFollowing testscripts are present:\n\t%s\n","\xAF" x 34;;
173 foreach (sort(keys(%tests))) {
174 print "\t\t" . $_ ."\n" if( /^[A-Z].*$/ );
176 printf "\n\t\%s\n\t%s\n","Be ensure, that usage is promitted by login and db status!","\xAF" x 58;
178 unlink("/tmp/lxtest-temp.conf");