@@ -5,14 +5,26 @@ create or replace package body test_suite_builder is
55 a_package_name varchar2 := 'TEST_SUITE_BUILDER_PACKAGE'
66 ) return clob is
77 l_suites ut3.ut_suite_builder.tt_schema_suites;
8+ l_suite ut3.ut_logical_suite;
89 l_cursor sys_refcursor;
10+ l_xml xmltype;
911 begin
1012 open l_cursor for select value(x) from table(
1113 ut3.ut_annotated_objects(
1214 ut3.ut_annotated_object('UT3_TESTER', a_package_name, 'PACKAGE', a_annotations)
1315 ) ) x;
1416 l_suites := ut3.ut_suite_builder.build_suites(l_cursor).schema_suites;
15- return xmltype(l_suites(l_suites.first)).getClobVal();
17+ l_suite := l_suites(l_suites.first);
18+
19+ select deletexml(
20+ xmltype(l_suite),
21+ '//RESULTS_COUNT|//START_TIME|//END_TIME|//RESULT|//ASSOCIATED_EVENT_NAME' ||
22+ '|//TRANSACTION_INVALIDATORS|//ERROR_BACKTRACE|//ERROR_STACK|//SERVEROUTPUT'
23+ )
24+ into l_xml
25+ from dual;
26+
27+ return l_xml.getClobVal();
1628 end;
1729
1830 procedure no_suite_description is
@@ -363,19 +375,19 @@ create or replace package body test_suite_builder is
363375 --Act
364376 l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
365377 --Assert
366- ut.expect(l_actual).match (
378+ ut.expect(l_actual).to_be_like (
367379 '<UT_LOGICAL_SUITE><SELF_TYPE>UT_SUITE</SELF_TYPE><OBJECT_OWNER>UT3_TESTER</OBJECT_OWNER>' ||
368380 '<OBJECT_NAME>some_package</OBJECT_NAME><NAME>some_package</NAME><DESCRIPTION>Cool</DESCRIPTION>' ||
369- '.* <WARNINGS><VARCHAR2>Annotations: "--%afterall", "--%aftereach", "--%beforeall", "--%beforeeach"' ||
381+ '% <WARNINGS><VARCHAR2>Annotations: "--\ %afterall", "--\ %aftereach", "--\ %beforeall", "--\ %beforeeach"' ||
370382 ' were ignored for procedure "DO_STUFF".' ||
371- ' Those annotations cannot be used with annotation: "--%test"</VARCHAR2></WARNINGS>'||
372- '.*<UT_SUITE_ITEM>.*<OBJECT_NAME>some_package</OBJECT_NAME>.*<NAME>do_stuff</NAME>' ||
373- '(.*<BEFORE_EACH_LIST/>)?' ||
374- '(.*<AFTER_EACH_LIST/>)?' ||
375- '(.*<BEFORE_ALL_LIST/>)?' ||
376- '(.*<AFTER_ALL_LIST/>)?'
383+ ' Those annotations cannot be used with annotation: "--\%test"</VARCHAR2></WARNINGS>'||
384+ '%<UT_SUITE_ITEM>%<OBJECT_NAME>some_package</OBJECT_NAME>%<NAME>do_stuff</NAME>%</UT_LOGICAL_SUITE>'
377385 ,'\'
378386 );
387+ ut.expect(l_actual).not_to_be_like('%<BEFORE_EACH_LIST>%');
388+ ut.expect(l_actual).not_to_be_like('%<AFTER_EACH_LIST>%');
389+ ut.expect(l_actual).not_to_be_like('%<BEFORE_ALL_LIST>%');
390+ ut.expect(l_actual).not_to_be_like('%<AFTER_ALL_LIST>%');
379391 end;
380392
381393 procedure suite_from_context is
@@ -423,6 +435,102 @@ create or replace package body test_suite_builder is
423435 );
424436 end;
425437
438+ procedure before_after_in_context is
439+ l_actual clob;
440+ l_annotations ut3.ut_annotations;
441+ begin
442+ --Arrange
443+ l_annotations := ut3.ut_annotations(
444+ ut3.ut_annotation(1, 'suite','Cool', null),
445+ ut3.ut_annotation(2, 'test','In suite', 'suite_level_test'),
446+ ut3.ut_annotation(3, 'context','A context', null),
447+ ut3.ut_annotation(4, 'beforeall',null, 'context_beforeall'),
448+ ut3.ut_annotation(5, 'beforeeach',null, 'context_beforeeach'),
449+ ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'),
450+ ut3.ut_annotation(7, 'aftereach',null, 'context_aftereach'),
451+ ut3.ut_annotation(8, 'afterall',null, 'context_afterall'),
452+ ut3.ut_annotation(9, 'endcontext',null, null)
453+ );
454+ --Act
455+ l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
456+ --Assert
457+ ut.expect(l_actual).to_be_like(
458+ '<UT_LOGICAL_SUITE>' ||
459+ '%<ITEMS>' ||
460+ '%<UT_SUITE_ITEM>' ||
461+ '%<NAME>context_1</NAME>' ||
462+ '%<ITEMS>' ||
463+ '%<UT_SUITE_ITEM>' ||
464+ '%<NAME>test_in_a_context</NAME>' ||
465+ '%<BEFORE_EACH_LIST>%<PROCEDURE_NAME>context_beforeeach</PROCEDURE_NAME>%</BEFORE_EACH_LIST>' ||
466+ '%<ITEM>%<PROCEDURE_NAME>test_in_a_context</PROCEDURE_NAME>%</ITEM>' ||
467+ '%<AFTER_EACH_LIST>%<PROCEDURE_NAME>context_aftereach</PROCEDURE_NAME>%</AFTER_EACH_LIST>' ||
468+ '%</UT_SUITE_ITEM>' ||
469+ '%</ITEMS>' ||
470+ '%<BEFORE_ALL_LIST>%<PROCEDURE_NAME>context_beforeall</PROCEDURE_NAME>%</BEFORE_ALL_LIST>' ||
471+ '%<AFTER_ALL_LIST>%<PROCEDURE_NAME>context_afterall</PROCEDURE_NAME>%</AFTER_ALL_LIST>' ||
472+ '%</UT_SUITE_ITEM>' ||
473+ '%<UT_SUITE_ITEM>' ||
474+ '%<NAME>suite_level_test</NAME>' ||
475+ '%<ITEM>%<PROCEDURE_NAME>suite_level_test</PROCEDURE_NAME>%</ITEM>' ||
476+ '%</UT_SUITE_ITEM>' ||
477+ '%</ITEMS>' ||
478+ '%</UT_LOGICAL_SUITE>'
479+ );
480+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<BEFORE_EACH_LIST>%</ITEMS>%');
481+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<AFTER_EACH_LIST>%</ITEMS>%');
482+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%</ITEMS>%<BEFORE_ALL_LIST>%');
483+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%</ITEMS>%<AFTER_ALL_LIST>%');
484+ end;
485+
486+ procedure before_after_out_of_context is
487+ l_actual clob;
488+ l_annotations ut3.ut_annotations;
489+ begin
490+ --Arrange
491+ l_annotations := ut3.ut_annotations(
492+ ut3.ut_annotation(1, 'suite','Cool', null),
493+ ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'),
494+ ut3.ut_annotation(3, 'beforeeach',null, 'suite_level_beforeeach'),
495+ ut3.ut_annotation(4, 'test','In suite', 'suite_level_test'),
496+ ut3.ut_annotation(5, 'context','A context', null),
497+ ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'),
498+ ut3.ut_annotation(7, 'endcontext',null, null),
499+ ut3.ut_annotation(8, 'aftereach',null, 'suite_level_aftereach'),
500+ ut3.ut_annotation(9, 'afterall',null, 'suite_level_afterall')
501+ );
502+ --Act
503+ l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
504+ --Assert
505+ ut.expect(l_actual).to_be_like(
506+ '<UT_LOGICAL_SUITE>' ||
507+ '%<ITEMS>' ||
508+ '%<UT_SUITE_ITEM>' ||
509+ '%<NAME>context_1</NAME>' ||
510+ '%<ITEMS>' ||
511+ '%<UT_SUITE_ITEM>' ||
512+ '%<NAME>test_in_a_context</NAME>' ||
513+ '%<ITEM>%<PROCEDURE_NAME>test_in_a_context</PROCEDURE_NAME>%</ITEM>' ||
514+ '%</UT_SUITE_ITEM>' ||
515+ '%</ITEMS>' ||
516+ '%</UT_SUITE_ITEM>' ||
517+ '%<UT_SUITE_ITEM>' ||
518+ '%<NAME>suite_level_test</NAME>' ||
519+ '%<BEFORE_EACH_LIST>%<PROCEDURE_NAME>suite_level_beforeeach</PROCEDURE_NAME>%</BEFORE_EACH_LIST>' ||
520+ '%<ITEM>%<PROCEDURE_NAME>suite_level_test</PROCEDURE_NAME>%</ITEM>' ||
521+ '%<AFTER_EACH_LIST>%<PROCEDURE_NAME>suite_level_aftereach</PROCEDURE_NAME>%</AFTER_EACH_LIST>' ||
522+ '%</UT_SUITE_ITEM>' ||
523+ '%</ITEMS>' ||
524+ '%<BEFORE_ALL_LIST>%<PROCEDURE_NAME>suite_level_beforeall</PROCEDURE_NAME>%</BEFORE_ALL_LIST>' ||
525+ '%<AFTER_ALL_LIST>%<PROCEDURE_NAME>suite_level_afterall</PROCEDURE_NAME>%</AFTER_ALL_LIST>' ||
526+ '%</UT_LOGICAL_SUITE>'
527+ );
528+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%<BEFORE_EACH_LIST>%</ITEMS>%</ITEMS>%');
529+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%<AFTER_EACH_LIST>%</ITEMS>%</ITEMS>%');
530+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<BEFORE_ALL_LIST>%</ITEMS>%');
531+ ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<AFTER_ALL_LIST>%</ITEMS>%');
532+ end;
533+
426534 procedure context_without_endcontext is
427535 l_actual clob;
428536 l_annotations ut3.ut_annotations;
0 commit comments