diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index 2bb9a87d9..f7e0b5ed0 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -134,9 +134,11 @@ create or replace package body ut_coverage_report_html_helper is l_file_part varchar2(32767); l_result ut_varchar2_rows := ut_varchar2_rows(); l_coverage_pct number(5, 2); - l_coverage_block_pct number(5, 2); l_hits varchar2(30); l_blocks varchar2(30); + l_line_text varchar2(32767); + e_buffer_too_small exception; + pragma exception_init ( e_buffer_too_small, -19011 ); begin l_coverage_pct := coverage_pct(a_coverage_unit.covered_lines, a_coverage_unit.uncovered_lines); @@ -148,10 +150,16 @@ create or replace package body ut_coverage_report_html_helper is ut_utils.append_to_list(l_result, l_file_part); for line_no in 1 .. a_source_code.count loop + begin + l_line_text := dbms_xmlgen.convert(a_source_code(line_no)); + exception + when e_buffer_too_small then + l_line_text := dbms_xmlgen.convert(to_clob(a_source_code(line_no))); + end; if not a_coverage_unit.lines.exists(line_no) then l_file_part := '
' || (dbms_xmlgen.convert(a_source_code(line_no))) ||
+ ' || l_line_text ||
'
' || (dbms_xmlgen.convert(a_source_code(line_no))) ||
+ ' || l_line_text ||
'
';
end if;
ut_utils.append_to_list(l_result, l_file_part);
@@ -222,7 +230,6 @@ create or replace package body ut_coverage_report_html_helper is
l_file_part varchar2(32767);
l_title varchar2(100) := 'All files';
l_coverage_pct number(5, 2);
- l_coverage_block_pct number(5, 2);
l_result ut_varchar2_rows;
l_id varchar2(50) := object_id(a_title);
l_unit_coverage ut_coverage.t_unit_coverage;
diff --git a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb
index d1645acae..2f2200116 100644
--- a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb
+++ b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb
@@ -32,5 +32,70 @@ create or replace package body test_html_coverage_reporter is
ut.expect(l_actual).to_be_like(l_expected);
end;
+ procedure setup_long_lines is
+ pragma autonomous_transaction;
+ begin
+
+ execute immediate q'[create or replace type string_array is table of varchar2(5 char);]';
+ execute immediate q'[
+ create or replace function f return integer is
+ l_string_array string_array;
+ l_count integer;
+ begin
+ -- line is 1912 chars long, 1911 characters seem to be the max. line length that works (@formatter:off)
+ l_string_array := string_array('aahed', 'aalii', 'aargh', 'aarti', 'abaca', 'abaci', 'abacs', 'abaft', 'abaka', 'abamp', 'aband', 'abash', 'abask', 'abaya', 'abbas', 'abbed', 'abbes', 'abcee', 'abeam', 'abear', 'abele', 'abers', 'abets', 'abies', 'abler', 'ables', 'ablet', 'ablow', 'abmho', 'abohm', 'aboil', 'aboma', 'aboon', 'abord', 'abore', 'abram', 'abray', 'abrim', 'abrin', 'abris', 'absey', 'absit', 'abuna', 'abune', 'abuts', 'abuzz', 'abyes', 'abysm', 'acais', 'acari', 'accas', 'accoy', 'acerb', 'acers', 'aceta', 'achar', 'ached', 'aches', 'achoo', 'acids', 'acidy', 'acing', 'acini', 'ackee', 'acker', 'acmes', 'acmic', 'acned', 'acnes', 'acock', 'acold', 'acred', 'acres', 'acros', 'acted', 'actin', 'acton', 'acyls', 'adaws', 'adays', 'adbot', 'addax', 'added', 'adder', 'addio', 'addle', 'adeem', 'adhan', 'adieu', 'adios', 'adits', 'adman', 'admen', 'admix', 'adobo', 'adown', 'adoze', 'adrad', 'adred', 'adsum', 'aduki', 'adunc', 'adust', 'advew', 'adyta', 'adzed', 'adzes', 'aecia', 'aedes', 'aegis', 'aeons', 'aerie', 'aeros', 'aesir', 'afald', 'afara', 'afars', 'afear', 'aflaj', 'afore', 'afrit', 'afros', 'agama', 'agami', 'agars', 'agast', 'agave', 'agaze', 'agene', 'agers', 'agger', 'aggie', 'aggri', 'aggro', 'aggry', 'aghas', 'agila', 'agios', 'agism', 'agist', 'agita', 'aglee', 'aglet', 'agley', 'agloo', 'aglus', 'agmas', 'agoge', 'agone', 'agons', 'agood', 'agora', 'agria', 'agrin', 'agros', 'agued', 'agues', 'aguna', 'aguti', 'aheap', 'ahent', 'ahigh', 'ahind', 'ahing', 'ahint', 'ahold', 'ahull', 'ahuru', 'aidas', 'aided', 'aides', 'aidoi', 'aidos', 'aiery', 'aigas', 'aight', 'ailed', 'aimed', 'aimer', 'ainee', 'ainga', 'aioli', 'aired', 'airer', 'airns', 'airth', 'airts', 'aitch', 'aitus', 'aiver', 'aiyee', 'aizle', 'ajies', 'ajiva', 'ajuga', 'ajwan', 'akees', 'akela', 'akene', 'aking', 'akita', 'akkas', 'alaap', 'alack', 'alamo', 'aland', 'alane', 'alang', 'a');
+ select count(*) into l_count from table(l_string_array);
+ return l_count;
+ end;]';
+
+ execute immediate q'[
+ create or replace package test_f is
+ --%suite
+
+ --%test
+ procedure fail_ut_coverage_html_reporter;
+ end;]';
+
+ execute immediate q'[
+ create or replace package body test_f is
+ procedure fail_ut_coverage_html_reporter is
+ begin
+ ut3_develop.ut.expect(f()).to_be_greater_or_equal(1);
+ end;
+ end;
+ ]';
+ end;
+
+ procedure cleanup_long_lines is
+ pragma autonomous_transaction;
+ begin
+ execute immediate 'drop package test_f';
+ execute immediate 'drop function f';
+ execute immediate 'drop type string_array force';
+ end;
+
+ procedure report_long_lines is
+ l_expected varchar2(32767);
+ l_actual clob;
+ l_name varchar2(250);
+ begin
+ --Arrange
+ l_expected := '%l_string_array := string_array%';
+
+ l_actual :=
+ ut3_tester_helper.coverage_helper.run_tests_as_job(
+ q'[
+ ut3_develop.ut.run(
+ a_path => 'ut3_user.test_f',
+ a_reporter=> ut3_develop.ut_coverage_html_reporter(),
+ a_include_objects => ut3_develop.ut_varchar2_list( 'UT3_USER.F' )
+ )
+ ]'
+ );
+ --Assert
+ ut.expect(l_actual).to_be_like(l_expected);
+ end;
+
+
end test_html_coverage_reporter;
/
diff --git a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks
index 629d41793..a11f3e912 100644
--- a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks
+++ b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks
@@ -6,5 +6,13 @@ create or replace package test_html_coverage_reporter is
--%test(reports on a project file mapped to database object in extended profiler coverage)
procedure report_on_file;
+ procedure setup_long_lines;
+ procedure cleanup_long_lines;
+
+ --%test(reports on lines exceeding 4000 chars after conversion to XML)
+ --%beforetest(setup_long_lines)
+ --%aftertest(cleanup_long_lines)
+ procedure report_long_lines;
+
end test_html_coverage_reporter;
/