From: Udo Spallek Date: Sat, 2 Dec 2006 16:30:02 +0000 (+0000) Subject: Verbesserungen am testframework... X-Git-Tag: release-2.4.0^2~135 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d14f75f9db5fdf62eb46aad98528f264e852c154;p=kivitendo-erp.git Verbesserungen am testframework... --- diff --git a/t/lx-office.t b/t/lx-office.t index a73d06af0..8ed77cdd9 100644 --- a/t/lx-office.t +++ b/t/lx-office.t @@ -36,7 +36,6 @@ use Carp; use Test::Harness; - ## Backendtests: # &runtests( # ); diff --git a/t/selenium/001CreateTestDatabase.t b/t/selenium/001CreateTestDatabase.t deleted file mode 100644 index bff24e423..000000000 --- a/t/selenium/001CreateTestDatabase.t +++ /dev/null @@ -1,32 +0,0 @@ -### Create Database - -diag("Create test database '$lxtest->{db}'"); - -$sel->open_ok($lxtest->{lxadmin}); -$sel->title_is("Lx-Office ERP Administration -"); - -$sel->open_ok($lxtest->{lxadmin}); -$sel->title_is("Lx-Office ERP Administration -"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP / Datenbankadministration -"); -$sel->type_ok("dbuser", $lxtest->{dbuser}); - -$sel->type_ok("dbpasswd", $lxtest->{dbpasswd}); -$sel->type_ok("dbuser", $lxtest->{dbuser}); -$sel->type_ok("dbhost", $lxtest->{dbhost}); -$sel->type_ok("dbport", $lxtest->{dbport}); -$sel->type_ok("dbdefault", $lxtest->{dbdefault}); - -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank anlegen\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -"); -$sel->type_ok("db", $lxtest->{db}); -$sel->select_ok("encoding", "label=ISO 8859-1"); -$sel->click_ok("//input[(\@name=\"chart\") and (\@value=\"Germany-DATEV-SKR03EU\")]"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong}); -$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP Administration -"); diff --git a/t/selenium/002CreateTestUser.t b/t/selenium/002CreateTestUser.t deleted file mode 100644 index aaf51d439..000000000 --- a/t/selenium/002CreateTestUser.t +++ /dev/null @@ -1,32 +0,0 @@ - -### Create new user -diag("Create test user '$lxtest->{testuserlogin}'"); -$sel->open_ok($lxtest->{lxadmin}); -$sel->title_is("Lx-Office ERP Administration -"); -$sel->click_ok("action"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP Administration / Benutzer erfassen -"); -$sel->type_ok("login", $lxtest->{testuserlogin}); -$sel->type_ok("password", $lxtest->{testuserpasswd}); -$sel->type_ok("name", "Selenium"); -$sel->type_ok("email", "selenium\@lx-office.org"); -$sel->type_ok("signature", "Selenium Testuser"); -$sel->type_ok("tel", "0000"); -$sel->type_ok("fax", "1111"); -$sel->type_ok("company", "Sel-enium"); -$sel->type_ok("signature", "Selenium Testuser\nTestfirma"); -$sel->type_ok("address", "Testfirma"); -$sel->type_ok("steuernummer", "111-222-333-444"); -$sel->type_ok("co_ustid", "1234567"); -$sel->type_ok("duns", "0987654321"); -$sel->click_ok("dbdriver"); -$sel->type_ok("newtemplates", "seleniumtestuser"); -$sel->click_ok("menustyle"); -$sel->type_ok("Pg_dbhost", $lxtest->{dbhost}); -$sel->type_ok("Pg_dbname", $lxtest->{db}); -$sel->type_ok("Pg_dbport", $lxtest->{dbport}); -$sel->type_ok("Pg_dbuser", $lxtest->{dbuser}); -$sel->type_ok("Pg_dbpasswd", $lxtest->{dbpasswd}); -$sel->click_ok("action"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP Administration -"); diff --git a/t/selenium/998DeleteTestUser.t b/t/selenium/998DeleteTestUser.t deleted file mode 100644 index f0c430e82..000000000 --- a/t/selenium/998DeleteTestUser.t +++ /dev/null @@ -1,9 +0,0 @@ -### Delete user -diag("Delete test user '$lxtest->{testuserlogin}'"); -$sel->open_ok($lxtest->{lxadmin}); -$sel->title_is("Lx-Office ERP Administration -"); -$sel->click_ok("link=$lxtest->{testuserlogin}"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP Administration / Benutzerdaten bearbeiten -"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Löschen\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); diff --git a/t/selenium/999DeleteTestDatabase.t b/t/selenium/999DeleteTestDatabase.t deleted file mode 100644 index 2bac58d90..000000000 --- a/t/selenium/999DeleteTestDatabase.t +++ /dev/null @@ -1,24 +0,0 @@ -#### Delete database -diag("Delete test database '$lxtest->{db}'"); - -$sel->open_ok($lxtest->{lxadmin}); -$sel->title_is("Lx-Office ERP Administration -"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP / Datenbankadministration -"); - -$sel->type_ok("dbhost", $lxtest->{dbhost}); -$sel->type_ok("dbport", $lxtest->{dbport}); -$sel->type_ok("dbuser", $lxtest->{dbuser}); -$sel->type_ok("dbpasswd", $lxtest->{dbpasswd}); - -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank löschen\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong}); -$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank löschen -"); -$sel->click_ok("//input[\@value=\"$lxtest->{db}\"]"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->body_text_is("Lx-Office ERP Datenbankadministration / Datenbank löschen $lxtest->{db} wurde erfolgreich gelöscht"); -$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); -$sel->wait_for_page_to_load_ok($lxtest->{timeout}); -$sel->title_is("Lx-Office ERP Administration -"); diff --git a/t/selenium/AllTests.t b/t/selenium/AllTests.t index 254472a6c..3c6acf66a 100644 --- a/t/selenium/AllTests.t +++ b/t/selenium/AllTests.t @@ -30,23 +30,41 @@ # ####################################################################### no strict; - push @INC, ['/tselenium']; + push @INC, ['/t/selenium']; use vars qw( $lxdebug $lxtest $sel ); use strict; - - use Test::WWW::Selenium; use Carp; - use Test::More tests => 86; # Need to be cutomized - diag('Pretests and initialisation'); + use Test::WWW::Selenium; + use Test::More; + use IO::Socket; - eval { require('t/lxtest.conf'); }; + eval { require('t/lxtest.conf'); }; if ($@) { diag("No test configuration found in t/lxtest.conf.\n Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n"); exit 0; }; + sub server_is_running { + return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost}, + PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport}, + ); + } + if (server_is_running) { + plan tests => 204; # Need to be cutomized + } + else { + plan skip_all => "No selenium server found! " + ."Maybe you forgot to start it or " + ."the preferences in t/lxtest.conf doesen't fit to your system"; + exit 0; + } + + diag('Pretests and initialisation'); + + + $lxtest->{test_id} = time; # create individual ids by unixtime $lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id}; $lxtest->{testuserpasswd} = $lxtest->{test_id}; @@ -62,11 +80,16 @@ $lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?path=$lxtest->{path}&rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; + + + eval { $sel = Test::WWW::Selenium->new( host => $lxtest->{seleniumhost}, port => $lxtest->{seleniumport}, browser => $lxtest->{seleniumbrowser}, - browser_url => $lxtest->{lxadmin}); + browser_url => $lxtest->{lxadmin}, + auto_stop => '0', + ); }; if ($@) { diag("No Selenium Server running, or wrong preferences\n\n"); @@ -77,11 +100,14 @@ diag('Starting Selenium tests...'); - require('t/selenium/001CreateTestDatabase.t'); - require('t/selenium/002CreateTestUser.t'); - - require('t/selenium/998DeleteTestUser.t'); - require('t/selenium/999DeleteTestDatabase.t'); + opendir(SCRIPTS, 't/selenium/testscripts'); + my @testscripts = sort readdir(SCRIPTS); + + foreach my $script (@testscripts){ + my $file = "t/selenium/testscripts/" . $script; + require_ok($file) if ( $script =~ /^\d\d\d.*\.t$/ ); + } + exit 1; $sel=''; # Destroy selenium object