Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fd99b8

Browse files
authored
Merge pull request #837 from utPLSQL/feature/warnings_overflow_fix
Added trimming of warning
2 parents ad54806 + fbc24b9 commit 7fd99b8

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

source/core/types/ut_suite_item.tpb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,24 @@ create or replace type body ut_suite_item as
6161

6262
member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2) is
6363
ex_savepoint_not_exists exception;
64+
l_transaction_invalidators clob;
6465
pragma exception_init(ex_savepoint_not_exists, -1086);
6566
begin
6667
if get_rollback_type() = ut_utils.gc_rollback_auto and a_savepoint is not null then
6768
execute immediate 'rollback to ' || a_savepoint;
6869
end if;
6970
exception
7071
when ex_savepoint_not_exists then
72+
l_transaction_invalidators :=
73+
lower( ut_utils.indent_lines( ut_utils.table_to_clob( self.get_transaction_invalidators() ), 2, true ) );
74+
if length(l_transaction_invalidators) > 3000 then
75+
l_transaction_invalidators := substr(l_transaction_invalidators,1,3000)||'...';
76+
end if;
7177
put_warning(
7278
'Unable to perform automatic rollback after test'
73-
|| case when self_type like '%SUITE' then ' suite' end || '. '
79+
|| case when self_type like '%SUITE' then ' suite' when self_type like '%CONTEXT' then ' context' end || '. '
7480
||'An implicit or explicit commit/rollback occurred in procedures:'||chr(10)
75-
||lower(ut_utils.indent_lines(ut_utils.table_to_clob(self.get_transaction_invalidators()), 2, true))||chr(10)
81+
||l_transaction_invalidators||chr(10)
7682
||'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.'
7783
);
7884
end;

test/core/test_ut_suite.pkb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,20 @@ create or replace package body test_ut_suite is
140140
begin
141141
test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) );
142142
end;
143+
144+
procedure trim_transaction_invalidators is
145+
l_suite ut3.ut_suite;
146+
begin
147+
--arrange
148+
l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1);
149+
for i in 1 .. 100 loop
150+
l_suite.add_transaction_invalidator('schema_name.package_name.procedure_name'||i);
151+
end loop;
152+
--Act
153+
l_suite.rollback_to_savepoint('dummy_savepoint');
154+
--Assert
155+
ut.expect(l_suite.warnings.count).to_equal(1);
156+
end;
157+
143158
end;
144159
/

test/core/test_ut_suite.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ create or replace package test_ut_suite is
3333
--%test(rollback(manual) - disables automatic rollback after a suite even if test fails)
3434
procedure rollback_manual_on_failure;
3535

36+
--%test(Transaction invalidators list is trimmed in warnings when too long)
37+
procedure trim_transaction_invalidators;
38+
3639
end;
3740
/

0 commit comments

Comments
 (0)