diff --git a/Code/ut_i_packages.sql b/Code/ut_i_packages.sql index 3f26e26..4df982f 100755 --- a/Code/ut_i_packages.sql +++ b/Code/ut_i_packages.sql @@ -36,3 +36,5 @@ @@ut_i_run ut_utoutput.pks @@ut_i_run ut_utreport.pks + +@@ut_i_run ut_wwwreporter.pks diff --git a/Code/ut_i_packages_b.sql b/Code/ut_i_packages_b.sql index e898857..2df64a6 100755 --- a/Code/ut_i_packages_b.sql +++ b/Code/ut_i_packages_b.sql @@ -36,3 +36,5 @@ @@ut_i_run ut_utoutput.pkb @@ut_i_run ut_utreport.pkb + +@@ut_i_run ut_wwwreporter.pkb \ No newline at end of file diff --git a/Code/ut_wwwreporter.pkb b/Code/ut_wwwreporter.pkb new file mode 100644 index 0000000..05072a6 --- /dev/null +++ b/Code/ut_wwwreporter.pkb @@ -0,0 +1,404 @@ +CREATE OR REPLACE PACKAGE BODY utWWWreporter +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log: ut_htmlreporter.pkb,v $ +Revision 1.2 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.1 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + + +************************************************************************/ +type tVar2000 is table of varchar2(2000) index by binary_integer; + +gn_nb number := 0; +gv_version varchar2(100) := 'iAS Web GUI for utPLSQL version 0.3'; +gv_author varchar2(100) := 'by Pierre-Gilles Levallois'; +gv_current_testing varchar2(2000) := '-'; +gn_current_nb_failure number := 0; +gn_current_nb_success number := 0; +gn_total_fail number := 0; +gn_total_success number := 0; +tHtml tVar2000; + +---------------------------------------------------------------------------- +-- add to html table. +---------------------------------------------------------------------------- +procedure addComment(pStr varchar2) is +begin + tHtml(nvl(tHtml.last, 0) + 1) := pStr; +end addComment; + +---------------------------------------------------------------------------- +-- displays html in the report. +---------------------------------------------------------------------------- +procedure displaySupplement is + i number; +begin + htp.p('
user comments & parameters'); + i := tHtml.first; + while (i is not null) loop + htp.p(tHtml(i)); + i := tHtml.next(i); + end loop; + htp.P('
'); +end displaySupplement; + +---------------------------------------------------------------------------- +-- displayPercentage : displays percentage total of successed tests +---------------------------------------------------------------------------- +procedure displayPercentage is +begin + htp.p(''); +exception +when others then + htp.p(sqlerrm); +end; +---------------------------------------------------------------------------- +-- header of the html page. +---------------------------------------------------------------------------- +procedure header is +begin + htp.p(''); +end header; + +---------------------------------------------------------------------------- +-- Show the config for a user +---------------------------------------------------------------------------- +PROCEDURE showconfig (username_in IN VARCHAR2 := NULL) + IS + lv_user varchar2(50) := utconfig.tester; + BEGIN + /* + --Get the configuration + rec := utconfig.config (v_user); + --Now show it + pl ('============================================================='); + pl ('utPLSQL Configuration for ' || v_user); + pl (' Directory: ' || rec.DIRECTORY); + pl (' Autcompile? ' || rec.autocompile); + pl (' Manual test registration? ' || rec.registertest); + pl (' Prefix = ' || rec.prefix); + pl (' Default reporter = ' || rec.reporter); + pl (' ----- File Output settings:'); + pl (' Output directory: ' || rec.filedir); + pl (' User prefix = ' || rec.fileuserprefix); + pl (' Include progname? ' || rec.fileincprogname); + pl (' Date format = ' || rec.filedateformat); + pl (' File extension = ' || rec.fileextension); + pl (' ----- End File Output settings'); + pl ('============================================================='); + */ + htp.p('
'); + htp.p('
 › Configuration for '||lv_user||'
'); + htp.p(''); + htp.p('
'); + END showconfig; + +-------------------------------------------------------------------------------- +-- css : put your own values for css +-------------------------------------------------------------------------------- +procedure css is +begin + htp.p(' + '); +end css; +-------------------------------------------------------------------------------- +-- open : opening web page +-------------------------------------------------------------------------------- + PROCEDURE open + IS + BEGIN + htp.p('test results'); + css; + htp.p('
+ + +
+
'); + header; + showconfig; + END open; + +-------------------------------------------------------------------------------- +-- close : closing web page +-------------------------------------------------------------------------------- + PROCEDURE close + IS + BEGIN + htp.p(''); + htp.p('
'); + END close; + +-------------------------------------------------------------------------------- +-- pl : printing a string +-------------------------------------------------------------------------------- + PROCEDURE pl (str VARCHAR2) + IS + BEGIN + htp.p(replace(str, chr(10), '
')||'
'); + END pl; + +-------------------------------------------------------------------------------- +-- pl_success : printing "Success" flag +-------------------------------------------------------------------------------- + PROCEDURE pl_success + IS + BEGIN + htp.p('Success'); + END pl_success; + +-------------------------------------------------------------------------------- +-- pl_failure : printing "FAILURE" flag +-------------------------------------------------------------------------------- + PROCEDURE pl_failure + IS + BEGIN + htp.p('FAILURE'); + END pl_failure; + +-------------------------------------------------------------------------------- +-- before_results : printing some stuff before printing results +-------------------------------------------------------------------------------- + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + utWWWreporter.open; + htp.p('

'|| utplsql.currpkg || ': '); + IF utresult.success (run_id) THEN + pl_success; + ELSE + pl_failure; + END IF; + htp.p(''); + htp.P('

'); + displaySupplement(); + htp.p('
Results:
'); + htp.p(''); + htp.p(''); + + END before_results; + +-------------------------------------------------------------------------------- +-- counttests : printing in a of tests after each tested function or proc. +-------------------------------------------------------------------------------- +procedure counttests is +begin + htp.p(''); + -- this is the end of a program testing. + htp.p(''); + htp.p(''); + gn_total_fail := gn_total_fail + gn_current_nb_failure; + gn_total_success := gn_total_success + gn_current_nb_success; +end; + +-------------------------------------------------------------------------------- +-- smartTitle : printing in a smart way the name of the tested proc. or Func. +-------------------------------------------------------------------------------- + procedure smartTitle is + new_testing varchar2(2000); + begin + new_testing := substr(utreport.outcome.description, 1, instr(utreport.outcome.description, ':')-1); + if ( new_testing != gv_current_testing ) then + -- the first time, no testcount... + if ( gv_current_testing != '-' ) then + countTests(); + end if; + gv_current_testing := new_testing; + gn_current_nb_failure := 0; + gn_current_nb_success := 0; + -- New program testing + htp.p(''); + htp.p(''); + htp.P(''); + end if; + end smartTitle; + +-------------------------------------------------------------------------------- +-- smartDesc : returning a smart printing of an failure or success description. +-------------------------------------------------------------------------------- + function smartDesc(pdesc varchar2) return varchar2 is + my_desc varchar2(4000) := substr(pdesc, instr(pdesc, ':')+1, length(pdesc)); + i number := 1; + tag varchar2(20); + lb_tag_opened boolean := false; + offset number; + begin + while i < length(my_desc) loop + if (substr(my_desc,i,1) = '"') then + if (lb_tag_opened) then + tag := ''; + offset := - 1; + lb_tag_opened := false; + my_desc := substr(my_desc,1,i + offset) || tag || substr(my_desc,i, length(my_desc)); + i := i + length(tag); + else + tag := ''; + lb_tag_opened := true; + offset := 1; + my_desc := substr(my_desc,1,i) || tag || substr(my_desc,i + offset, length(my_desc)); + end if; + end if; + i := i + 1; + end loop; + + return my_desc; + end smartDesc; + +-------------------------------------------------------------------------------- +-- show_failure : printing details of a failure +-------------------------------------------------------------------------------- + PROCEDURE show_failure + IS + BEGIN + smartTitle; + htp.p(''); + END show_failure; + +-------------------------------------------------------------------------------- +-- show_result : printing results +-------------------------------------------------------------------------------- + PROCEDURE show_result + IS + odd_even varchar2(100); + BEGIN + if ( MOD(gn_nb, 2) = 1) then + odd_even := 'impair'; + else + odd_even := 'pair'; + end if; + + smartTitle; + + htp.p (''); + gn_nb := gn_nb + 1; + END show_result; + +-------------------------------------------------------------------------------- +-- after_results : printing some stuff after results are printed +-------------------------------------------------------------------------------- + procedure after_results(run_id in utr_outcome.run_id%type) + is + begin + counttests(); + htp.p('
#StatusDescription% Success
'|| + to_char(round(100* gn_current_nb_success / (gn_current_nb_success + gn_current_nb_failure), 2))|| + '%
 › Testing program "'||new_testing||'"...
'||gn_nb||''); + pl_failure; + htp.p('' || smartDesc(utreport.outcome.description) || '
'||gn_nb||''); + + IF utreport.outcome.status = 'SUCCESS' THEN + pl_success; + gn_current_nb_success := gn_current_nb_success + 1; + ELSE + pl_failure; + gn_current_nb_failure := gn_current_nb_failure + 1; + END IF; + + htp.p('' || smartDesc(utreport.outcome.description) || '
'); + displayPercentage(); + end after_results; + +-------------------------------------------------------------------------------- +-- before_errors : printing some stuff before printing errors +-------------------------------------------------------------------------------- + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE) + IS + + cursor c_err is + select e.errlevel, e.errcode, e.description + from utr_error e; + lr_err c_err%rowtype; + + BEGIN + htp.p('
Errors:
'); + htp.p(''); + + open c_err; + loop + fetch c_err into lr_err; + exit when c_err%notfound; + htp.p(''); + end loop; + close c_err; + + END before_errors; + +-------------------------------------------------------------------------------- +-- show_error : printing errors +-------------------------------------------------------------------------------- + PROCEDURE show_error + IS + BEGIN + utreport.pl (''); + END show_error; + +-------------------------------------------------------------------------------- +-- after_errors : printing some stuff after errors are printed +-------------------------------------------------------------------------------- + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + htp.p('
Error LevelError CodeDescription
'||lr_err.errlevel||''||lr_err.errcode||''||lr_err.description||'
' || utreport.error.errlevel || + '' || utreport.error.errcode || + '' || utreport.error.errtext || '
'); +-- utWWWreporter.close; + END after_errors; + +END utWWWreporter; +/ diff --git a/Code/ut_wwwreporter.pks b/Code/ut_wwwreporter.pks new file mode 100644 index 0000000..110300e --- /dev/null +++ b/Code/ut_wwwreporter.pks @@ -0,0 +1,47 @@ +CREATE OR REPLACE PACKAGE utWWWreporter +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log + +************************************************************************/ + + PROCEDURE open; + PROCEDURE pl (str IN VARCHAR2); + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE); + PROCEDURE show_failure; + PROCEDURE show_result; + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE); + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE); + PROCEDURE show_error; + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE); + + PROCEDURE close; + + + procedure addComment(pStr varchar2); + +END utWWWreporter; +/