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

Skip to content

Commit fbd4514

Browse files
committed
Added reporting of warnings for unknown annotations.
Resolves #624
1 parent 512bb1c commit fbd4514

3 files changed

Lines changed: 88 additions & 3 deletions

File tree

source/core/ut_suite_builder.pkb

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ create or replace package body ut_suite_builder is
3737
gc_context constant t_annotation_name := 'context';
3838
gc_endcontext constant t_annotation_name := 'endcontext';
3939

40+
type tt_annotations is table of t_annotation_name;
41+
42+
gc_supported_annotations constant tt_annotations
43+
:= tt_annotations(
44+
gc_suite,
45+
gc_suitepath,
46+
gc_test,
47+
gc_disabled,
48+
gc_displayname,
49+
gc_beforeall,
50+
gc_beforeeach,
51+
gc_beforetest,
52+
gc_afterall,
53+
gc_aftereach,
54+
gc_aftertest,
55+
gc_throws,
56+
gc_rollback,
57+
gc_context,
58+
gc_endcontext
59+
);
60+
4061
gc_placeholder constant varchar2(3) := '\\%';
4162

4263
gc_integer_exception constant varchar2(1) := 'I';
@@ -757,7 +778,27 @@ create or replace package body ut_suite_builder is
757778
end loop;
758779
end if;
759780
end;
760-
781+
782+
procedure warning_on_unknown_annotations(
783+
a_suite in out nocopy ut_suite_item,
784+
a_annotations tt_annotations_by_line
785+
) is
786+
l_line_no t_annotation_position := a_annotations.first;
787+
begin
788+
while l_line_no is not null loop
789+
if a_annotations(l_line_no).name not member of (gc_supported_annotations) then
790+
add_annotation_ignored_warning(
791+
a_suite,
792+
a_annotations(l_line_no).name,
793+
'Unsupported annotation %%%.',
794+
l_line_no,
795+
a_annotations(l_line_no).procedure_name
796+
);
797+
end if;
798+
l_line_no := a_annotations.next(l_line_no);
799+
end loop;
800+
end;
801+
761802
function create_suite(
762803
a_annotations t_annotations_info
763804
) return ut_logical_suite is
@@ -771,6 +812,7 @@ create or replace package body ut_suite_builder is
771812
l_suite := ut_suite(l_annotations.owner, l_annotations.name);
772813
l_annotation_pos := l_annotations.by_name( gc_suite).first;
773814
l_suite.description := l_annotations.by_name( gc_suite)( l_annotation_pos);
815+
warning_on_unknown_annotations(l_suite, l_annotations.by_line);
774816

775817
warning_on_duplicate_annot( l_suite, l_annotations.by_name, gc_suite );
776818

test/core/test_suite_builder.pkb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,5 +1020,37 @@ create or replace package body test_suite_builder is
10201020
);
10211021
end;
10221022

1023-
end;
1023+
procedure test_bad_procedure_annotation is
1024+
l_actual clob;
1025+
l_annotations ut3.ut_annotations;
1026+
begin
1027+
--Arrange
1028+
l_annotations := ut3.ut_annotations(
1029+
ut3.ut_annotation(1, 'suite','Cool', null),
1030+
ut3.ut_annotation(2, 'bad_procedure_annotation',null, 'some_procedure'),
1031+
ut3.ut_annotation(6, 'test','A test', 'do_stuff')
1032+
);
1033+
--Act
1034+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1035+
--Assert
1036+
ut.expect(l_actual).to_be_like('%<WARNINGS><VARCHAR2>Unsupported annotation &quot;--\%bad_procedure_annotation&quot;. Annotation ignored.% line 2</VARCHAR2></WARNINGS>%', '\');
1037+
end;
1038+
1039+
procedure test_bad_package_annotation is
1040+
l_actual clob;
1041+
l_annotations ut3.ut_annotations;
1042+
begin
1043+
--Arrange
1044+
l_annotations := ut3.ut_annotations(
1045+
ut3.ut_annotation(1, 'suite','Cool', null),
1046+
ut3.ut_annotation(17, 'bad_package_annotation',null, null),
1047+
ut3.ut_annotation(24, 'test','A test', 'do_stuff')
1048+
);
1049+
--Act
1050+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1051+
--Assert
1052+
ut.expect(l_actual).to_be_like('%<WARNINGS><VARCHAR2>Unsupported annotation &quot;--\%bad_package_annotation&quot;. Annotation ignored.% line 17</VARCHAR2></WARNINGS>%', '\');
1053+
end;
1054+
1055+
end test_suite_builder;
10241056
/

test/core/test_suite_builder.pks

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,16 @@ create or replace package test_suite_builder is
163163

164164
--%endcontext
165165

166-
end;
166+
--%context(unknown_annotation)
167+
--%displayname(--%bad_annotation)
168+
169+
--%test(Gives warning when unknown procedure level annotation passed)
170+
procedure test_bad_procedure_annotation;
171+
172+
--%test(Gives warning when unknown package level annotation passed)
173+
procedure test_bad_package_annotation;
174+
175+
--%endcontext
176+
177+
end test_suite_builder;
167178
/

0 commit comments

Comments
 (0)