1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
BEGIN{
use strict;
use rcconfig;
use Test::More tests =>1;
}
END
{
my $rcserver = rcconfig->new();
my $rchost = $rcserver->get_rchost();
my $rcport = $rcserver->get_rcport();
my $rcbrowser = $rcserver->get_rcbrowser();
my $rcurl = $rcserver->get_rcurl();
my $obj = WWW::Selenium -> new(host => $rchost,
port => $rcport,
browser => $rcbrowser,
browser_url => $rcurl);
$obj->start();
is($obj->open("/cosmo_90/"),'OK','Domain oeffnen');
$obj->stop();
}
1;
Das ist ein kleines Testscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
my @required_config_files = ("test_definitions",
"rcconfig");
my $file;
foreach $file (@required_config_files){
eval"use $file";
if($@){
print "<p class=\"error\"><b>$file</b> - Datei/Modul konnte nicht geladen werden:<br /> $@ <br /></p>\n";
}
}
if($@){
print "</body></html>\n";
exit;
}
else{
print"<p>Konfiguration wurde erfolgreich geladen</p>";
}
my $test_def = test_definitions->new();
my $test_ref = $test_def->getTests();
my %tests = %$test_ref;
my $test;
my $key;
my @errors;
my $error;
my $UA = new LWP::UserAgent;
my $count_tests = keys %tests;
my $count_ok = 0;
my $count_fail = 0;
my $config_error_flag;
my $script_error_flag;
my $script_file;
my @required_keys = ('title','legend','type');
foreach $test (sort keys %tests){
$config_error_flag = 0;
$script_error_flag = 0;
my @missing_keys = ();
my @missing_scripts = ();
foreach $key (@required_keys){
unless($tests{$test}->{$key}){
push(@missing_keys,$key);
$config_error_flag = 1;
}
}
$script_file = "$source_cgi$dir_suite$script_dir/".$tests{$test}->{type}."/$test";
unless(-e $script_file){
push(@missing_scripts,$test);
$script_error_flag = 1;
}
if($config_error_flag){
my $errStr = "$test: configuration: Keys not defined: ".join(',',@missing_keys)."<br>";
push(@errors,$errStr);
unless($script_error_flag){
next;
}
}
if($script_error_flag){
my $errStr = "$test: Script: File not found: ".join(',',@missing_scripts)."<br>";
push(@errors,$errStr);
next;
}
my @results = ();
print "<p class=\"ok\">$test:";
print"<ul>";
foreach $key (sort keys %{$tests{$test}}){
print"<li>$key: $tests{$test}->{$key}</li>";
}
print"</ul></p>";
if(require $script_file){
$count_ok++;
}
}
print"Anzahl definierter Tests: $count_tests<br>";
print "Anzahl erfolgreich abgeschlossener Testst: $count_ok";
$count_fail = @errors;
print"<p class=\"error\">Es gab $count_fail Fehler:<br>";
foreach $error (@errors){
print $error;
}
print"</p>";
print "</body></html>\n";
Und das die überprüfung der Config und Aufrufen der Testscripte
EDIT:
Die Ausgaben von Test::More tauchen im HTML-Dokument aber erst nach Ausgabe aller Fehler im Array @errors auf.
Leider hat ein Eval-Block nicht den gewünschten Effekt gezeigt, bei fehlerhaftem Script wird die AUsführung des Hauptprogramms trotzdem unterbrochen...