Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding an extra test to extend coverage.
  • Loading branch information
jgebal committed Jun 9, 2026
commit bfd1a9aac18d796347d30c48bd17f9022850f79e
2 changes: 2 additions & 0 deletions source/core/types/ut_executable_test.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
return remap_no_data_found(
coalesce(
get_exception_no(a_exception_var),
get_exception_no(a_item.object_name||'.'||a_exception_var),
get_exception_no(a_item.object_owner||'.'||a_exception_var),
get_exception_no(a_item.object_owner||'.'||a_item.object_name||'.'||a_exception_var)
)
Expand All @@ -93,6 +94,7 @@
begin
return coalesce(
verify_name(a_exception_var),
verify_name(a_item.object_name||'.'||a_exception_var),
verify_name(a_item.object_owner||'.'||a_exception_var),
verify_name(a_item.object_owner||'.'||a_item.object_name||'.'||a_exception_var)
);
Expand All @@ -103,11 +105,11 @@
a_exception_names_list := ut_varchar2_rows();
a_exception_numbers_list := ut_varchar2_rows();
if a_exception_definitions is not empty then
for i in 1 .. a_exception_definitions.count loop

Check failure on line 108 in source/core/types/ut_executable_test.tpb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this FOR loop by a more robust WHILE one.

See more on https://sonarcloud.io/project/issues?id=utPLSQL_utPLSQL&issues=AZ6sPAfNRD0Uh5IywUbW&open=AZ6sPAfNRD0Uh5IywUbW&pullRequest=1366
l_exception_number :=
coalesce(
to_exception_number(a_exception_definitions(i), a_item),
to_number(a_exception_definitions(i) default null on conversion error )

Check warning on line 112 in source/core/types/ut_executable_test.tpb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Provide the format of the input value.

See more on https://sonarcloud.io/project/issues?id=utPLSQL_utPLSQL&issues=AZ6sPAfNRD0Uh5IywUbX&open=AZ6sPAfNRD0Uh5IywUbX&pullRequest=1366
);
l_exception_name := to_exception_name(a_exception_definitions(i), a_item);

Expand All @@ -134,7 +136,7 @@
end if;
end;

function get_exception_failure_message(a_expected_errors_list ut_varchar2_rows) return varchar is

Check warning on line 139 in source/core/types/ut_executable_test.tpb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use VARCHAR2 instead of VARCHAR.

See more on https://sonarcloud.io/project/issues?id=utPLSQL_utPLSQL&issues=AZ6sPAfNRD0Uh5IywUbY&open=AZ6sPAfNRD0Uh5IywUbY&pullRequest=1366
l_actual_error_no integer;
l_expected_errors varchar2(4000);
l_fail_message varchar2(4000);
Expand Down
15 changes: 15 additions & 0 deletions test/ut3_tester/core/annotations/test_annot_throws_exception.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ is
--%throws(e_uninitialized_exception_variable)
procedure referencing_uninitialized_exception;

--%test(Failure report shows all expected exceptions)
--%throws(c_local_error_no,e_some_local_exception,e_uninitialized_exception_variable)
procedure not_throwing_expected_exceptions;

end;
]';

Expand Down Expand Up @@ -297,6 +301,11 @@ is
begin
raise e_uninitialized_exception_variable;
end;

procedure not_throwing_expected_exceptions is
begin
raise_application_error(-20143, ''Test error'');
end;
end;
';

Expand Down Expand Up @@ -497,5 +506,11 @@ is
ut.expect(l_actual).not_to_match('referencing_uninitialized_exception');
end;

procedure not_throwing_expected_exceptions is
begin
ut.expect(g_tests_results).to_match('not_throwing_expected_exceptions');
ut.expect(g_tests_results).to_match('Actual: -20143 was expected to be one of: \(annotated_package_with_throws.e_some_local_exception, annotated_package_with_throws.e_uninitialized_exception_variable, -20211\)');
end;

end;
/
11 changes: 7 additions & 4 deletions test/ut3_tester/core/annotations/test_annot_throws_exception.pks
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ is
--%test(Detects a valid exception number within many invalid ones)
procedure one_valid_exception_number;

--%test(Gives failure when a exception is expected and nothing is thrown)
--%test(Gives failure when an exception is expected and nothing is thrown)
procedure nothing_thrown;

--%test(Single exception defined as a constant number in package)
Expand All @@ -49,13 +49,13 @@ is
--%test(Gives success when one of annotated exception using constant is thrown)
procedure list_of_exc_constant;

--%test(Gives failure when the raised exception is different that the annotated one using variable)
--%test(Gives failure when the raised exception is different than the annotated one using variable)
procedure fail_not_match_exc;

--%test(Success when one of exception from mixed list of number and constant is thrown)
--%test(Success when one of exception from a mixed list of number and constant is thrown)
procedure mixed_exc_list;

--%test(Success when match exception even if other variable on list dont exists)
--%test(Success when match exception even if another variable on list doesn't exists)
procedure mixed_list_notexi;

--%test(Success resolve and match named exception defined in pragma exception init)
Expand All @@ -81,6 +81,9 @@ is

--%test(Uninitialized exception variable can be used successfully in a test)
procedure referencing_uninitialized_exception;

--%test(a Failure report shows all expected exceptions)
procedure not_throwing_expected_exceptions;

--%context(referencing exceptions when running from another schema)

Expand Down
Loading