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

Skip to content

Commit 1a941a8

Browse files
committed
Adding Tests to tags #suitebuilder
1 parent 777a2af commit 1a941a8

4 files changed

Lines changed: 361 additions & 7 deletions

File tree

source/core/ut_suite_builder.pkb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ create or replace package body ut_suite_builder is
314314
a_tags_ann_text tt_annotation_texts
315315
) is
316316
l_annotation_pos binary_integer;
317+
l_tag_list ut_varchar2_list := ut_varchar2_list();
317318
begin
318319
l_annotation_pos := a_tags_ann_text.first;
319320
while l_annotation_pos is not null loop
@@ -323,9 +324,13 @@ create or replace package body ut_suite_builder is
323324
|| chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || l_annotation_pos
324325
);
325326
else
326-
a_list :=
327-
a_list || a_tags_ann_text(l_annotation_pos);
327+
l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements(
328+
ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')
329+
);
328330
end if;
331+
a_list := ut_utils.table_to_clob(
332+
ut_utils.filter_list(l_tag_list,'^(\w|\S)+$'),
333+
',');
329334
l_annotation_pos := a_tags_ann_text.next(l_annotation_pos);
330335
end loop;
331336

@@ -621,7 +626,7 @@ create or replace package body ut_suite_builder is
621626
a_tags_ann_text tt_annotation_texts
622627
) is
623628
l_annotation_pos binary_integer;
624-
l_tags varchar2(4000);
629+
l_tag_list ut_varchar2_list := ut_varchar2_list();
625630
begin
626631
l_annotation_pos := a_tags_ann_text.first;
627632
while l_annotation_pos is not null loop
@@ -630,12 +635,15 @@ create or replace package body ut_suite_builder is
630635
'"--%tag" annotation requires a tag value populated. Annotation ignored, line ' || l_annotation_pos
631636
);
632637
else
633-
l_tags :=
634-
l_tags || a_tags_ann_text(l_annotation_pos);
638+
l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements(
639+
ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')
640+
);
635641
end if;
636642
l_annotation_pos := a_tags_ann_text.next(l_annotation_pos);
637643
end loop;
638-
a_suite.tags := l_tags;
644+
a_suite.tags := ut_utils.table_to_clob(
645+
ut_utils.filter_list(l_tag_list,'^(\w|\S)+$'),
646+
',');
639647
end;
640648

641649
procedure add_suite_tests(

source/core/ut_utils.pkb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ create or replace package body ut_utils is
610610
if a_list is not null then
611611
l_filtered_list := ut_varchar2_list();
612612
l_index := a_list.first;
613-
614613
while (l_index is not null) loop
615614
if regexp_like(a_list(l_index), a_regexp_filter) then
616615
l_filtered_list.extend;

test/ut3_tester/core/test_suite_builder.pkb

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,5 +1121,305 @@ create or replace package body test_suite_builder is
11211121
ut.expect(l_actual).to_match('(.*)(<WARNINGS><VARCHAR2>Unsupported annotation &quot;--%bad_package_annotation&quot;\. Annotation ignored\.)(.*)( line 17</VARCHAR2></WARNINGS>)(.*)', 'n');
11221122
end;
11231123

1124+
procedure test_tag_annotation is
1125+
l_actual clob;
1126+
l_annotations ut3.ut_annotations;
1127+
begin
1128+
--Arrange
1129+
l_annotations := ut3.ut_annotations(
1130+
ut3.ut_annotation(2, 'suite','testsuite', null),
1131+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1132+
ut3.ut_annotation(9, 'tag','testtag', 'test_procedure')
1133+
);
1134+
--Act
1135+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1136+
--Assert
1137+
ut.expect(l_actual).to_be_like(
1138+
'%<UT_SUITE_ITEM>' ||
1139+
'%<NAME>test_procedure</NAME><DESCRIPTION>Some test</DESCRIPTION><PATH>some_package.test_procedure</PATH>' ||
1140+
'%<TAGS>testtag</TAGS>%'||
1141+
'%</UT_SUITE_ITEM>%'
1142+
);
1143+
1144+
end;
1145+
1146+
procedure suite_tag_annotation is
1147+
l_actual clob;
1148+
l_annotations ut3.ut_annotations;
1149+
begin
1150+
--Arrange
1151+
l_annotations := ut3.ut_annotations(
1152+
ut3.ut_annotation(2, 'suite','testsuite', null),
1153+
ut3.ut_annotation(3, 'tag','suitetag', null)
1154+
);
1155+
--Act
1156+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1157+
--Assert
1158+
ut.expect(l_actual).to_be_like(
1159+
'%<UT_LOGICAL_SUITE>' ||
1160+
'%<NAME>some_package</NAME><DESCRIPTION>testsuite</DESCRIPTION><PATH>some_package</PATH>' ||
1161+
'%<TAGS>suitetag</TAGS>%'||
1162+
'%</UT_LOGICAL_SUITE>%'
1163+
);
1164+
1165+
end;
1166+
1167+
procedure test_tags_annotation is
1168+
l_actual clob;
1169+
l_annotations ut3.ut_annotations;
1170+
begin
1171+
--Arrange
1172+
l_annotations := ut3.ut_annotations(
1173+
ut3.ut_annotation(2, 'suite','testsuite', null),
1174+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1175+
ut3.ut_annotation(9, 'tag','testtag,testtag2,testtag3', 'test_procedure')
1176+
);
1177+
--Act
1178+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1179+
--Assert
1180+
ut.expect(l_actual).to_be_like(
1181+
'%<UT_SUITE_ITEM>' ||
1182+
'%<NAME>test_procedure</NAME><DESCRIPTION>Some test</DESCRIPTION><PATH>some_package.test_procedure</PATH>' ||
1183+
'%<TAGS>testtag,testtag2,testtag3</TAGS>%'||
1184+
'%</UT_SUITE_ITEM>%'
1185+
);
1186+
1187+
end;
1188+
1189+
procedure suite_tags_annotation is
1190+
l_actual clob;
1191+
l_annotations ut3.ut_annotations;
1192+
begin
1193+
--Arrange
1194+
l_annotations := ut3.ut_annotations(
1195+
ut3.ut_annotation(2, 'suite','testsuite', null),
1196+
ut3.ut_annotation(3, 'tag','suitetag,suitetag1,suitetag2', null)
1197+
);
1198+
--Act
1199+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1200+
--Assert
1201+
ut.expect(l_actual).to_be_like(
1202+
'%<UT_LOGICAL_SUITE>' ||
1203+
'%<NAME>some_package</NAME><DESCRIPTION>testsuite</DESCRIPTION><PATH>some_package</PATH>' ||
1204+
'%<TAGS>suitetag,suitetag1,suitetag2</TAGS>%'||
1205+
'%</UT_LOGICAL_SUITE>%'
1206+
);
1207+
1208+
end;
1209+
1210+
procedure test_2line_tags_annotation is
1211+
l_actual clob;
1212+
l_annotations ut3.ut_annotations;
1213+
begin
1214+
--Arrange
1215+
l_annotations := ut3.ut_annotations(
1216+
ut3.ut_annotation(2, 'suite','testsuite', null),
1217+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1218+
ut3.ut_annotation(9, 'tag','testtag', 'test_procedure'),
1219+
ut3.ut_annotation(10, 'tag','testtag2', 'test_procedure')
1220+
);
1221+
--Act
1222+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1223+
--Assert
1224+
ut.expect(l_actual).to_be_like(
1225+
'%<UT_SUITE_ITEM>' ||
1226+
'%<NAME>test_procedure</NAME><DESCRIPTION>Some test</DESCRIPTION><PATH>some_package.test_procedure</PATH>' ||
1227+
'%<TAGS>testtag,testtag2</TAGS>%'||
1228+
'%</UT_SUITE_ITEM>%'
1229+
);
1230+
1231+
end;
1232+
1233+
procedure suite_2line_tags_annotation is
1234+
l_actual clob;
1235+
l_annotations ut3.ut_annotations;
1236+
begin
1237+
--Arrange
1238+
l_annotations := ut3.ut_annotations(
1239+
ut3.ut_annotation(2, 'suite','testsuite', null),
1240+
ut3.ut_annotation(3, 'tag','suitetag', null),
1241+
ut3.ut_annotation(4, 'tag','suitetag1', null)
1242+
);
1243+
--Act
1244+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1245+
--Assert
1246+
ut.expect(l_actual).to_be_like(
1247+
'%<UT_LOGICAL_SUITE>' ||
1248+
'%<NAME>some_package</NAME><DESCRIPTION>testsuite</DESCRIPTION><PATH>some_package</PATH>' ||
1249+
'%<TAGS>suitetag,suitetag1</TAGS>%'||
1250+
'%</UT_LOGICAL_SUITE>%'
1251+
);
1252+
1253+
end;
1254+
1255+
procedure test_empty_tag is
1256+
l_actual clob;
1257+
l_annotations ut3.ut_annotations;
1258+
begin
1259+
l_annotations := ut3.ut_annotations(
1260+
ut3.ut_annotation(2, 'suite','testsuite', null),
1261+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1262+
ut3.ut_annotation(9, 'tag',null, 'test_procedure')
1263+
);
1264+
--Act
1265+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1266+
--Assert
1267+
ut.expect(l_actual).to_be_like(
1268+
'%<WARNINGS>%&quot;--%tag&quot; annotation requires a tag value populated. Annotation ignored.%</WARNINGS>%'||
1269+
'%<TAGS/>%'
1270+
);
1271+
1272+
end;
1273+
1274+
procedure suite_empty_tag is
1275+
l_actual clob;
1276+
l_annotations ut3.ut_annotations;
1277+
begin
1278+
--Arrange
1279+
l_annotations := ut3.ut_annotations(
1280+
ut3.ut_annotation(2, 'suite','testsuite', null),
1281+
ut3.ut_annotation(3, 'tag',null, null)
1282+
);
1283+
--Act
1284+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1285+
--Assert
1286+
ut.expect(l_actual).to_be_like(
1287+
'%<WARNINGS><VARCHAR2>&quot;--%tag&quot; annotation requires a tag value populated. Annotation ignored, line 3</VARCHAR2></WARNINGS>%'||
1288+
'%<TAGS/>%'
1289+
);
1290+
1291+
end;
1292+
1293+
procedure test_duplicate_tag is
1294+
l_actual clob;
1295+
l_annotations ut3.ut_annotations;
1296+
begin
1297+
--Arrange
1298+
l_annotations := ut3.ut_annotations(
1299+
ut3.ut_annotation(2, 'suite','testsuite', null),
1300+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1301+
ut3.ut_annotation(9, 'tag','testtag,testtag1,testtag', 'test_procedure'),
1302+
ut3.ut_annotation(10, 'tag',' testtag,testtag1,testtag2', 'test_procedure')
1303+
);
1304+
--Act
1305+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1306+
--Assert
1307+
ut.expect(l_actual).to_be_like(
1308+
'%<UT_SUITE_ITEM>' ||
1309+
'%<NAME>test_procedure</NAME><DESCRIPTION>Some test</DESCRIPTION><PATH>some_package.test_procedure</PATH>' ||
1310+
'%<TAGS>testtag,testtag1,testtag2</TAGS>%'||
1311+
'%</UT_SUITE_ITEM>%'
1312+
);
1313+
1314+
end;
1315+
1316+
procedure suite_duplicate_tag is
1317+
l_actual clob;
1318+
l_annotations ut3.ut_annotations;
1319+
begin
1320+
--Arrange
1321+
l_annotations := ut3.ut_annotations(
1322+
ut3.ut_annotation(2, 'suite','testsuite', null),
1323+
ut3.ut_annotation(3, 'tag','suitetag,suitetag1,suitetag', null),
1324+
ut3.ut_annotation(4, 'tag',' suitetag1,suitetag2', null)
1325+
);
1326+
--Act
1327+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1328+
--Assert
1329+
ut.expect(l_actual).to_be_like(
1330+
'%<UT_LOGICAL_SUITE>' ||
1331+
'%<NAME>some_package</NAME><DESCRIPTION>testsuite</DESCRIPTION><PATH>some_package</PATH>' ||
1332+
'%<TAGS>suitetag,suitetag1,suitetag2</TAGS>%'||
1333+
'%</UT_LOGICAL_SUITE>%'
1334+
);
1335+
1336+
end;
1337+
1338+
procedure test_empty_tag_between is
1339+
l_actual clob;
1340+
l_annotations ut3.ut_annotations;
1341+
begin
1342+
--Arrange
1343+
l_annotations := ut3.ut_annotations(
1344+
ut3.ut_annotation(2, 'suite','testsuite', null),
1345+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1346+
ut3.ut_annotation(9, 'tag','testtag,, ,testtag1', 'test_procedure')
1347+
);
1348+
--Act
1349+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1350+
--Assert
1351+
ut.expect(l_actual).to_be_like(
1352+
'%<UT_SUITE_ITEM>' ||
1353+
'%<NAME>test_procedure</NAME><DESCRIPTION>Some test</DESCRIPTION><PATH>some_package.test_procedure</PATH>' ||
1354+
'%<TAGS>testtag,testtag1</TAGS>%'||
1355+
'%</UT_SUITE_ITEM>%'
1356+
);
1357+
1358+
end;
1359+
1360+
procedure suite_empty_tag_between is
1361+
l_actual clob;
1362+
l_annotations ut3.ut_annotations;
1363+
begin
1364+
--Arrange
1365+
l_annotations := ut3.ut_annotations(
1366+
ut3.ut_annotation(2, 'suite','testsuite', null),
1367+
ut3.ut_annotation(3, 'tag','suitetag,, ,suitetag1', null)
1368+
);
1369+
--Act
1370+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1371+
--Assert
1372+
ut.expect(l_actual).to_be_like(
1373+
'%<UT_LOGICAL_SUITE>' ||
1374+
'%<NAME>some_package</NAME><DESCRIPTION>testsuite</DESCRIPTION><PATH>some_package</PATH>' ||
1375+
'%<TAGS>suitetag,suitetag1</TAGS>%'||
1376+
'%</UT_LOGICAL_SUITE>%'
1377+
);
1378+
1379+
end;
1380+
1381+
procedure test_special_char_tag is
1382+
l_actual clob;
1383+
l_annotations ut3.ut_annotations;
1384+
begin
1385+
--Arrange
1386+
l_annotations := ut3.ut_annotations(
1387+
ut3.ut_annotation(2, 'suite','testsuite', null),
1388+
ut3.ut_annotation(8, 'test','Some test', 'test_procedure'),
1389+
ut3.ut_annotation(9, 'tag','#?$%^&*!|\/@][', 'test_procedure')
1390+
);
1391+
--Act
1392+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1393+
--Assert
1394+
ut.expect(l_actual).to_be_like(
1395+
'%<UT_SUITE_ITEM>' ||
1396+
'%<NAME>test_procedure</NAME><DESCRIPTION>Some test</DESCRIPTION><PATH>some_package.test_procedure</PATH>' ||
1397+
'%<TAGS>#?$%^&amp;*!|\/@][</TAGS>%'||
1398+
'%</UT_SUITE_ITEM>%'
1399+
);
1400+
1401+
end;
1402+
1403+
procedure suite_special_char_tag is
1404+
l_actual clob;
1405+
l_annotations ut3.ut_annotations;
1406+
begin
1407+
--Arrange
1408+
l_annotations := ut3.ut_annotations(
1409+
ut3.ut_annotation(2, 'suite','testsuite', null),
1410+
ut3.ut_annotation(3, 'tag','#?$%^&*!|\/@][', null)
1411+
);
1412+
--Act
1413+
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
1414+
--Assert
1415+
ut.expect(l_actual).to_be_like(
1416+
'%<UT_LOGICAL_SUITE>' ||
1417+
'%<NAME>some_package</NAME><DESCRIPTION>testsuite</DESCRIPTION><PATH>some_package</PATH>' ||
1418+
'%<TAGS>#?$%^&amp;*!|\/@][</TAGS>%'||
1419+
'%</UT_LOGICAL_SUITE>%'
1420+
);
1421+
1422+
end;
1423+
11241424
end test_suite_builder;
11251425
/

0 commit comments

Comments
 (0)