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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c787e47
Added support for multiple occurrences of before and after blocks.
jgebal Mar 4, 2018
2399981
tmp
jgebal Mar 14, 2018
2631355
Fixed issue with null items list.
jgebal Mar 15, 2018
a05475a
Redefined event listeners mechanism.
jgebal Mar 25, 2018
f955d2a
Redefined event listeners mechanism.
jgebal Mar 25, 2018
430f76f
Fixed minor bug in XUnit reporter (showing CDATA for errors even when…
jgebal Mar 25, 2018
2537ced
Changed propagation of rollback. Now rollback will propagate from par…
jgebal Mar 29, 2018
9308662
Fixed examples.
jgebal Mar 29, 2018
17ee8cb
Fixed test for empty description in 11g.
jgebal Mar 29, 2018
93be873
Fixed test for empty description in 11g.
jgebal Mar 29, 2018
75b96c3
Fixed double warning on missing endcontext annotation.
jgebal Mar 29, 2018
a6dadcc
fix in test to overcome 11g XML missing attributes in 3.0.4
jgebal Mar 30, 2018
4bc7ced
Merge branch 'develop' into feature/support_of_context
jgebal Apr 7, 2018
8a26845
Fixes after merging from develop.
jgebal Apr 7, 2018
e9c4e80
Fixed test failure on 11g R2 - some issues with LIKE operator, long p…
jgebal Apr 7, 2018
bfbfa43
Updated documentation.
jgebal Apr 7, 2018
9cd61bf
Marking first column as bold
jgebal Apr 7, 2018
1adf35d
Changed the way reporters events are registered.
jgebal Apr 14, 2018
71d0b70
Fixed issues with comment-replace in big package specs.
jgebal Apr 14, 2018
8617613
Updated test for comments removal to include multi-line comments with…
jgebal Apr 16, 2018
51ba943
Updated documentation with new and changed annotations.
jgebal Apr 16, 2018
ad3f830
Changed behaviour for duplicate annotations - first wins.
jgebal Apr 19, 2018
4346b57
Updates to documentation.
jgebal Apr 20, 2018
b1ff0fc
Updates to documentation.
jgebal Apr 20, 2018
ab5a1ca
Updated and extended documentation for annotations.
jgebal Apr 22, 2018
e672ef0
Added description of `context` to annotations documentation.
jgebal Apr 22, 2018
9897247
Merge remote-tracking branch 'origin/develop' into feature/support_of…
jgebal Apr 22, 2018
b2df93e
Integrated with develop branch changes.
jgebal Apr 22, 2018
d604127
Removed empty header from documentation.
jgebal Apr 24, 2018
9afb7be
A bit of code cleanup and tests alignment.
jgebal Apr 25, 2018
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
Fixes after merging from develop.
Added additional tests for suite_builder.
Adjusted variable names to  match convention.
Fixed setting of nls_params for XMLTYPE conversion using DBMS_XMLGEN.
  • Loading branch information
jgebal committed Apr 7, 2018
commit 8a2684534c71475eb321692c47ca573ab62caba7
28 changes: 14 additions & 14 deletions source/core/events/ut_event_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ create or replace package body ut_event_manager as
type t_listener_numbers is table of boolean index by t_listener_number;
type t_events_listeners is table of t_listener_numbers index by t_event_name;

gc_event_listeners_index t_events_listeners;
gc_listeners t_listeners;
g_event_listeners_index t_events_listeners;
g_listeners t_listeners;

procedure initialize is
begin
gc_event_listeners_index.delete;
gc_listeners := t_listeners();
g_event_listeners_index.delete;
g_listeners := t_listeners();
end;

procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item ) is
begin
if a_event_name is not null and gc_event_listeners_index.exists(a_event_name)
and gc_event_listeners_index(a_event_name) is not null
if a_event_name is not null and g_event_listeners_index.exists(a_event_name)
and g_event_listeners_index(a_event_name) is not null
then
for listener_number in 1 .. gc_event_listeners_index(a_event_name).count loop
gc_listeners(listener_number).on_event(a_event_name, a_event_object);
for listener_number in 1 .. g_event_listeners_index(a_event_name).count loop
g_listeners(listener_number).on_event(a_event_name, a_event_object);
end loop;
end if;
end;

procedure add_event( a_event_name t_event_name, a_listener_pos binary_integer ) is
begin
gc_event_listeners_index(a_event_name)(a_listener_pos) := true;
g_event_listeners_index(a_event_name)(a_listener_pos) := true;
end;

procedure add_events( a_event_names ut_varchar2_list, a_listener_pos binary_integer ) is
Expand All @@ -55,12 +55,12 @@ create or replace package body ut_event_manager as

function add_listener( a_listener ut_event_listener ) return t_listener_number is
begin
if gc_listeners is null then
gc_listeners := t_listeners();
if g_listeners is null then
g_listeners := t_listeners();
end if;
gc_listeners.extend;
gc_listeners(gc_listeners.last) := a_listener;
return gc_listeners.last;
g_listeners.extend;
g_listeners(g_listeners.last) := a_listener;
return g_listeners.last;
end;

procedure add_listener( a_listener ut_event_listener ) is
Expand Down
34 changes: 17 additions & 17 deletions source/core/ut_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ create or replace package body ut_suite_builder is

function get_procedure_annotations(a_annotations ut_annotations, a_index binary_integer) return tt_procedure_annotations is
l_result tt_procedure_annotations;
i binary_integer := a_index;
l_index binary_integer := a_index;
begin
loop
l_result(a_annotations(i).name)(i) := a_annotations(i).text;
exit when is_last_annotation_for_proc(a_annotations, i);
i := a_annotations.next(i);
l_result(a_annotations(l_index).name)(l_index) := a_annotations(l_index).text;
exit when is_last_annotation_for_proc(a_annotations, l_index);
l_index := a_annotations.next(l_index);
end loop;
return l_result;
end;
Expand Down Expand Up @@ -102,14 +102,14 @@ create or replace package body ut_suite_builder is

function build_annotation_index(a_annotations tt_package_annotations ) return tt_annotations_index is
l_result tt_annotations_index;
i binary_integer;
l_idx binary_integer;
begin
i := a_annotations.first;
while i is not null loop
if a_annotations(i).name is not null then
l_result(a_annotations(i).name)(i) := true;
l_idx := a_annotations.first;
while l_idx is not null loop
if a_annotations(l_idx).name is not null then
l_result(a_annotations(l_idx).name)(l_idx) := true;
end if;
i := a_annotations.next(i);
l_idx := a_annotations.next(l_idx);
end loop;
return l_result;
end;
Expand All @@ -119,15 +119,15 @@ create or replace package body ut_suite_builder is
a_start_pos t_annotation_position,
a_end_pos t_annotation_position
) is
i t_annotation_name;
l_idx t_annotation_name;
begin
i := a_index.first;
while i is not null loop
a_index(i).delete(a_start_pos, a_end_pos);
if a_index(i).count = 0 then
a_index.delete(i);
l_idx := a_index.first;
while l_idx is not null loop
a_index( l_idx ).delete( a_start_pos, a_end_pos);
if a_index( l_idx ).count = 0 then
a_index.delete( l_idx );
end if;
i := a_index.next(i);
l_idx := a_index.next( l_idx );
end loop;
end;

Expand Down
2 changes: 1 addition & 1 deletion source/expectations/data_values/ut_data_value_anydata.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ create or replace type body ut_data_value_anydata as
self.is_data_null := 1;
end if;
if not self.is_null() then
open l_query for select a_value val from dual;
ut_expectation_processor.set_xml_nls_params();
open l_query for select a_value val from dual;
l_ctx := sys.dbms_xmlgen.newcontext( l_query );
dbms_xmlgen.setrowtag(l_ctx, '');
dbms_xmlgen.setrowsettag(l_ctx, '');
Expand Down
12 changes: 8 additions & 4 deletions source/reporters/ut_tfs_junit_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ create or replace type body ut_tfs_junit_reporter is
l_tests_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count +
a_suite.results_count.failure_count + a_suite.results_count.errored_count;
l_suite ut_suite;
l_outputs clob;
l_errors ut_varchar2_list;
begin

for i in 1 .. a_suite.items.count loop
Expand All @@ -114,20 +116,22 @@ create or replace type body ut_tfs_junit_reporter is
end if;
end loop;
l_suite := treat(a_suite as ut_suite);
if l_suite.before_all.serveroutput is not null or l_suite.after_all.serveroutput is not null then
l_outputs := l_suite.get_serveroutputs();
if l_outputs is not null and l_outputs != empty_clob() then
self.print_text('<system-out>');
self.print_text('<![CDATA[');
self.print_clob(l_suite.get_serveroutputs());
self.print_clob(l_outputs);
self.print_text(']]>');
self.print_text('</system-out>');
else
self.print_text('<system-out/>');
end if;

if l_suite.before_all.error_stack is not null or l_suite.after_all.error_stack is not null then
l_errors := l_suite.get_error_stack_traces();
if l_errors is not empty then
self.print_text('<system-err>');
self.print_text('<![CDATA[');
self.print_text(trim(l_suite.before_all.error_stack) || trim(chr(10) || chr(10) || l_suite.after_all.error_stack));
self.print_clob(ut_utils.table_to_clob(l_errors));
self.print_text(']]>');
self.print_text('</system-err>');
else
Expand Down
5 changes: 1 addition & 4 deletions test/core/reporters/test_tfs_junit_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ create or replace package body test_tfs_junit_reporter as
ut.expect(l_actual).to_be_like('<testsuites>
<testsuite tests="0" id="1" package="core.check_junit_rep_suitepath.check_junit_flat_suitepath" errors="0" failures="0" name="flatsuitepath" time="%" timestamp="%" hostname="%" >
<properties/>
<system-out>
<![CDATA[
]]>
</system-out>
<system-out/>
<system-err/>
</testsuite>%');
end;
Expand Down
126 changes: 117 additions & 9 deletions test/core/test_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ create or replace package body test_suite_builder is
a_package_name varchar2 := 'TEST_SUITE_BUILDER_PACKAGE'
) return clob is
l_suites ut3.ut_suite_builder.tt_schema_suites;
l_suite ut3.ut_logical_suite;
l_cursor sys_refcursor;
l_xml xmltype;
begin
open l_cursor for select value(x) from table(
ut3.ut_annotated_objects(
ut3.ut_annotated_object('UT3_TESTER', a_package_name, 'PACKAGE', a_annotations)
) ) x;
l_suites := ut3.ut_suite_builder.build_suites(l_cursor).schema_suites;
return xmltype(l_suites(l_suites.first)).getClobVal();
l_suite := l_suites(l_suites.first);

select deletexml(
xmltype(l_suite),
'//RESULTS_COUNT|//START_TIME|//END_TIME|//RESULT|//ASSOCIATED_EVENT_NAME' ||
'|//TRANSACTION_INVALIDATORS|//ERROR_BACKTRACE|//ERROR_STACK|//SERVEROUTPUT'
)
into l_xml
from dual;

return l_xml.getClobVal();
end;

procedure no_suite_description is
Expand Down Expand Up @@ -363,19 +375,19 @@ create or replace package body test_suite_builder is
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).match(
ut.expect(l_actual).to_be_like(
'<UT_LOGICAL_SUITE><SELF_TYPE>UT_SUITE</SELF_TYPE><OBJECT_OWNER>UT3_TESTER</OBJECT_OWNER>' ||
'<OBJECT_NAME>some_package</OBJECT_NAME><NAME>some_package</NAME><DESCRIPTION>Cool</DESCRIPTION>' ||
'.*<WARNINGS><VARCHAR2>Annotations: &quot;--%afterall&quot;, &quot;--%aftereach&quot;, &quot;--%beforeall&quot;, &quot;--%beforeeach&quot;' ||
'%<WARNINGS><VARCHAR2>Annotations: &quot;--\%afterall&quot;, &quot;--\%aftereach&quot;, &quot;--\%beforeall&quot;, &quot;--\%beforeeach&quot;' ||
' were ignored for procedure &quot;DO_STUFF&quot;.' ||
' Those annotations cannot be used with annotation: &quot;--%test&quot;</VARCHAR2></WARNINGS>'||
'.*<UT_SUITE_ITEM>.*<OBJECT_NAME>some_package</OBJECT_NAME>.*<NAME>do_stuff</NAME>' ||
'(.*<BEFORE_EACH_LIST/>)?' ||
'(.*<AFTER_EACH_LIST/>)?' ||
'(.*<BEFORE_ALL_LIST/>)?' ||
'(.*<AFTER_ALL_LIST/>)?'
' Those annotations cannot be used with annotation: &quot;--\%test&quot;</VARCHAR2></WARNINGS>'||
'%<UT_SUITE_ITEM>%<OBJECT_NAME>some_package</OBJECT_NAME>%<NAME>do_stuff</NAME>%</UT_LOGICAL_SUITE>'
,'\'
);
ut.expect(l_actual).not_to_be_like('%<BEFORE_EACH_LIST>%');
ut.expect(l_actual).not_to_be_like('%<AFTER_EACH_LIST>%');
ut.expect(l_actual).not_to_be_like('%<BEFORE_ALL_LIST>%');
ut.expect(l_actual).not_to_be_like('%<AFTER_ALL_LIST>%');
end;

procedure suite_from_context is
Expand Down Expand Up @@ -423,6 +435,102 @@ create or replace package body test_suite_builder is
);
end;

procedure before_after_in_context is
l_actual clob;
l_annotations ut3.ut_annotations;
begin
--Arrange
l_annotations := ut3.ut_annotations(
ut3.ut_annotation(1, 'suite','Cool', null),
ut3.ut_annotation(2, 'test','In suite', 'suite_level_test'),
ut3.ut_annotation(3, 'context','A context', null),
ut3.ut_annotation(4, 'beforeall',null, 'context_beforeall'),
ut3.ut_annotation(5, 'beforeeach',null, 'context_beforeeach'),
ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'),
ut3.ut_annotation(7, 'aftereach',null, 'context_aftereach'),
ut3.ut_annotation(8, 'afterall',null, 'context_afterall'),
ut3.ut_annotation(9, 'endcontext',null, null)
);
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).to_be_like(
'<UT_LOGICAL_SUITE>' ||
'%<ITEMS>' ||
'%<UT_SUITE_ITEM>' ||
'%<NAME>context_1</NAME>' ||
'%<ITEMS>' ||
'%<UT_SUITE_ITEM>' ||
'%<NAME>test_in_a_context</NAME>' ||
'%<BEFORE_EACH_LIST>%<PROCEDURE_NAME>context_beforeeach</PROCEDURE_NAME>%</BEFORE_EACH_LIST>' ||
'%<ITEM>%<PROCEDURE_NAME>test_in_a_context</PROCEDURE_NAME>%</ITEM>' ||
'%<AFTER_EACH_LIST>%<PROCEDURE_NAME>context_aftereach</PROCEDURE_NAME>%</AFTER_EACH_LIST>' ||
'%</UT_SUITE_ITEM>' ||
'%</ITEMS>' ||
'%<BEFORE_ALL_LIST>%<PROCEDURE_NAME>context_beforeall</PROCEDURE_NAME>%</BEFORE_ALL_LIST>' ||
'%<AFTER_ALL_LIST>%<PROCEDURE_NAME>context_afterall</PROCEDURE_NAME>%</AFTER_ALL_LIST>' ||
'%</UT_SUITE_ITEM>' ||
'%<UT_SUITE_ITEM>' ||
'%<NAME>suite_level_test</NAME>' ||
'%<ITEM>%<PROCEDURE_NAME>suite_level_test</PROCEDURE_NAME>%</ITEM>' ||
'%</UT_SUITE_ITEM>' ||
'%</ITEMS>' ||
'%</UT_LOGICAL_SUITE>'
);
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<BEFORE_EACH_LIST>%</ITEMS>%');
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<AFTER_EACH_LIST>%</ITEMS>%');
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%</ITEMS>%<BEFORE_ALL_LIST>%');
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%</ITEMS>%<AFTER_ALL_LIST>%');
end;

procedure before_after_out_of_context is
l_actual clob;
l_annotations ut3.ut_annotations;
begin
--Arrange
l_annotations := ut3.ut_annotations(
ut3.ut_annotation(1, 'suite','Cool', null),
ut3.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'),
ut3.ut_annotation(3, 'beforeeach',null, 'suite_level_beforeeach'),
ut3.ut_annotation(4, 'test','In suite', 'suite_level_test'),
ut3.ut_annotation(5, 'context','A context', null),
ut3.ut_annotation(6, 'test', 'In context', 'test_in_a_context'),
ut3.ut_annotation(7, 'endcontext',null, null),
ut3.ut_annotation(8, 'aftereach',null, 'suite_level_aftereach'),
ut3.ut_annotation(9, 'afterall',null, 'suite_level_afterall')
);
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).to_be_like(
'<UT_LOGICAL_SUITE>' ||
'%<ITEMS>' ||
'%<UT_SUITE_ITEM>' ||
'%<NAME>context_1</NAME>' ||
'%<ITEMS>' ||
'%<UT_SUITE_ITEM>' ||
'%<NAME>test_in_a_context</NAME>' ||
'%<ITEM>%<PROCEDURE_NAME>test_in_a_context</PROCEDURE_NAME>%</ITEM>' ||
'%</UT_SUITE_ITEM>' ||
'%</ITEMS>' ||
'%</UT_SUITE_ITEM>' ||
'%<UT_SUITE_ITEM>' ||
'%<NAME>suite_level_test</NAME>' ||
'%<BEFORE_EACH_LIST>%<PROCEDURE_NAME>suite_level_beforeeach</PROCEDURE_NAME>%</BEFORE_EACH_LIST>' ||
'%<ITEM>%<PROCEDURE_NAME>suite_level_test</PROCEDURE_NAME>%</ITEM>' ||
'%<AFTER_EACH_LIST>%<PROCEDURE_NAME>suite_level_aftereach</PROCEDURE_NAME>%</AFTER_EACH_LIST>' ||
'%</UT_SUITE_ITEM>' ||
'%</ITEMS>' ||
'%<BEFORE_ALL_LIST>%<PROCEDURE_NAME>suite_level_beforeall</PROCEDURE_NAME>%</BEFORE_ALL_LIST>' ||
'%<AFTER_ALL_LIST>%<PROCEDURE_NAME>suite_level_afterall</PROCEDURE_NAME>%</AFTER_ALL_LIST>' ||
'%</UT_LOGICAL_SUITE>'
);
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%<BEFORE_EACH_LIST>%</ITEMS>%</ITEMS>%');
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%<AFTER_EACH_LIST>%</ITEMS>%</ITEMS>%');
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<BEFORE_ALL_LIST>%</ITEMS>%');
ut.expect(l_actual).not_to_be_like('%<ITEMS>%<ITEMS>%</ITEMS>%<AFTER_ALL_LIST>%</ITEMS>%');
end;

procedure context_without_endcontext is
l_actual clob;
l_annotations ut3.ut_annotations;
Expand Down
8 changes: 7 additions & 1 deletion test/core/test_suite_builder.pks
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ create or replace package test_suite_builder is
--%test(Creates nested suite for content between context/endcontext annotations)
procedure suite_from_context;

--%test(Associates before/after all/each to tests in context only)
procedure before_after_in_context;

--%test(Does not propagate before/after each to context)
procedure before_after_out_of_context;

--%test(Does not create context and gives warning when endcontext is missing)
procedure context_without_endcontext;

--%test(Gives warning when endcontext is missing a preceding context)
--%test(Gives warning if --%endcontext is missing a preceding --%context)
procedure endcontext_without_context;

end;
Expand Down