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
Merge remote-tracking branch 'origin/develop' into feature/support_of…
…_context

# Conflicts:
#	docs/userguide/annotations.md
#	source/api/ut_runner.pkb
#	source/core/types/ut_run.tps
#	source/core/ut_utils.pkb
#	source/core/ut_utils.pks
#	source/reporters/ut_xunit_reporter.tpb
#	test/install_tests.sql
  • Loading branch information
jgebal committed Apr 22, 2018
commit 9897247940e74fe8bc4955f3e292578a0277985c
3 changes: 2 additions & 1 deletion docs/userguide/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,8 @@ Example:
exec ut_runner.rebuild_annotation_cache('HR');
```

To purge the annotation cache call `ut_runner.purge_cache(a_object_owner)`.
To purge the annotation cache call `ut_runner.purge_cache(a_object_owner, a_object_type)`.
Both parameters are optional and if not provided, all owners/object_types will be purged.
Example:
```sql
exec ut_runner.purge_cache('HR', 'PACKAGE');
Expand Down
72 changes: 43 additions & 29 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ create or replace package body ut_runner is
a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
) is
l_run ut_run;
l_run ut_run;
l_coverage_schema_names ut_varchar2_rows;
l_exclude_object_names ut_object_names := ut_object_names();
l_include_object_names ut_object_names;
begin
ut_event_manager.initialize();
begin
Expand All @@ -93,6 +96,21 @@ create or replace package body ut_runner is
ut_event_manager.add_listener(a_reporters(i));
end loop;
end if;

if a_coverage_schemes is not empty then
l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes);
else
l_coverage_schema_names := ut_suite_manager.get_schema_names(a_paths);
end if;

if a_exclude_objects is not empty then
l_exclude_object_names := to_ut_object_list(a_exclude_objects, l_coverage_schema_names);
end if;

l_exclude_object_names := l_exclude_object_names multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);

l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names);

l_run := ut_run(
ut_suite_manager.configure_execution_by_path(a_paths),
a_paths,
Expand Down Expand Up @@ -155,38 +173,34 @@ create or replace package body ut_runner is
return;
end;

function get_reporters_list return tt_reporters_info pipelined
AS
function get_reporters_list return tt_reporters_info pipelined is
l_cursor sys_refcursor;
l_owner varchar2(128) := ut_utils.ut_owner();
l_owner varchar2(128) := upper(ut_utils.ut_owner());
l_results tt_reporters_info;
c_bulk_limit constant integer := 10;
begin
open l_cursor for 'SELECT
owner || ''.'' || type_name,
CASE
WHEN sys_connect_by_path(owner
|| ''.''
|| type_name,'','') LIKE ''%' || l_owner || '''
|| ''.UT_OUTPUT_REPORTER_BASE%'' THEN ''Y''
ELSE ''N''
END
is_output_reporter
FROM dba_types t
WHERE instantiable = ''YES''
CONNECT BY supertype_name = PRIOR type_name AND supertype_owner = PRIOR owner
START WITH type_name = ''UT_REPORTER_BASE'' AND owner = '''|| l_owner || '''';
loop
fetch l_cursor bulk collect into l_results limit c_bulk_limit;
for i in 1 .. l_results.count loop
pipe row (l_results(i));
end loop;
exit when l_cursor%notfound;
l_view_name varchar2(200) := ut_metadata.get_dba_view('dba_types');
begin
open l_cursor for q'[
SELECT
owner || '.' || type_name,
CASE
WHEN sys_connect_by_path(owner||'.'||type_name,',') LIKE '%]' || l_owner || q'[.UT_OUTPUT_REPORTER_BASE%'
THEN 'Y'
ELSE 'N'
END is_output_reporter
FROM ]'||l_view_name||q'[ t
WHERE instantiable = 'YES'
CONNECT BY supertype_name = PRIOR type_name AND supertype_owner = PRIOR owner
START WITH type_name = 'UT_REPORTER_BASE' AND owner = ']'|| l_owner || '''';
loop
fetch l_cursor bulk collect into l_results limit c_bulk_limit;
for i in 1 .. l_results.count loop
pipe row (l_results(i));
end loop;
close l_cursor;
end;


exit when l_cursor%notfound;
end loop;
close l_cursor;
end;

end ut_runner;
/
3 changes: 1 addition & 2 deletions source/core/types/ut_run.tps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
create or replace type ut_run force under ut_suite_item (
create or replace type ut_run under ut_suite_item (
/*
utPLSQL - Version 3
Copyright 2016 - 2017 utPLSQL Project
Expand Down Expand Up @@ -37,7 +37,6 @@ create or replace type ut_run force under ut_suite_item (
overriding member function do_execute(self in out nocopy ut_run) return boolean,
overriding member procedure calc_execution_result(self in out nocopy ut_run),
overriding member procedure mark_as_errored(self in out nocopy ut_run, a_error_stack_trace varchar2),
member function get_run_schemes return ut_varchar2_rows,
overriding member function get_error_stack_traces return ut_varchar2_list,
overriding member function get_serveroutputs return clob
)
Expand Down
14 changes: 13 additions & 1 deletion source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,19 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab,
return l_filtered_list;
end;


function xmlgen_escaped_string(a_string in varchar2) return varchar2 is
l_result varchar2(4000);
l_sql varchar2(32767) := q'!select q'[!'||a_string||q'!]' as "!'||a_string||'" from dual';
begin
if a_string is not null then
select extract(dbms_xmlgen.getxmltype(l_sql),'/*/*/*').getRootElement()
into l_result
from dual;
else
l_result := a_string;
end if;
return l_result;
end;

function replace_multiline_comments(a_source clob) return clob is
l_result clob;
Expand Down
3 changes: 3 additions & 0 deletions source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ create or replace package ut_utils authid definer is
/*It takes a collection of type ut_varchar2_list and it only returns the elements which meets the regular expression*/
function filter_list(a_list IN ut_varchar2_list, a_regexp_filter in varchar2) return ut_varchar2_list;

-- Generates XMLGEN escaped string
function xmlgen_escaped_string(a_string in varchar2) return varchar2;

/**
* Replaces multi-line comments in given source-code with empty lines
*/
Expand Down
111 changes: 0 additions & 111 deletions source/reporters/ut_xunit_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -22,117 +22,6 @@ create or replace type body ut_xunit_reporter is
return;
end;

overriding member procedure after_calling_run(self in out nocopy ut_xunit_reporter, a_run in ut_run) is
l_suite_id integer := 0;
l_tests_count integer := a_run.results_count.disabled_count + a_run.results_count.success_count +
a_run.results_count.failure_count + a_run.results_count.errored_count;

function get_path(a_path_with_name varchar2, a_name varchar2) return varchar2 is
begin
return regexp_substr(a_path_with_name, '(.*)\.' ||a_name||'$',subexpression=>1);
end;

procedure print_test_elements(a_test ut_test) is
l_lines ut_varchar2_list;
l_output clob;
begin
self.print_text('<testcase classname="' || dbms_xmlgen.convert(get_path(a_test.path, a_test.name)) || '" ' || ' assertions="' ||
nvl(a_test.all_expectations.count,0) || '"' || self.get_common_item_attributes(a_test) || case when
a_test.result != ut_utils.gc_success then
' status="' || ut_utils.test_result_to_char(a_test.result) || '"' end || '>');
if a_test.result = ut_utils.gc_disabled then
self.print_text('<skipped/>');
end if;
if a_test.result = ut_utils.gc_error then
self.print_text('<error>');
self.print_text('<![CDATA[');
self.print_clob(ut_utils.table_to_clob(a_test.get_error_stack_traces()));
self.print_text(']]>');
self.print_text('</error>');
elsif a_test.result > ut_utils.gc_success then
self.print_text('<failure>');
self.print_text('<![CDATA[');
for i in 1 .. a_test.failed_expectations.count loop
l_lines := a_test.failed_expectations(i).get_result_lines();
for j in 1 .. l_lines.count loop
self.print_text(l_lines(j));
end loop;
self.print_text(a_test.failed_expectations(i).caller_info);
end loop;
self.print_text(']]>');
self.print_text('</failure>');
end if;
-- TODO - decide if we need/want to use the <system-err/> tag too
l_output := a_test.get_serveroutputs();
if l_output is not null then
self.print_text('<system-out>');
self.print_text('<![CDATA[');
self.print_clob(l_output);
self.print_text(']]>');
self.print_text('</system-out>');
end if;
self.print_text('</testcase>');
end;

procedure print_suite_elements(a_suite ut_logical_suite, a_suite_id in out nocopy integer) 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_data clob;
l_errors ut_varchar2_list;
begin
a_suite_id := a_suite_id + 1;
self.print_text('<testsuite tests="' || l_tests_count || '"' || ' id="' || a_suite_id || '"' || ' package="' ||
dbms_xmlgen.convert(a_suite.path) || '" ' || self.get_common_item_attributes(a_suite) || '>');
if a_suite is of(ut_suite) then
l_suite := treat(a_suite as ut_suite);

l_data := l_suite.get_serveroutputs();
if l_data is not null and l_data != empty_clob() then
self.print_text('<system-out>');
self.print_text('<![CDATA[');
self.print_clob(l_data);
self.print_text(']]>');
self.print_text('</system-out>');
end if;

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_clob(ut_utils.table_to_clob(l_errors));
self.print_text(']]>');
self.print_text('</system-err>');
end if;
end if;

for i in 1 .. a_suite.items.count loop
if a_suite.items(i) is of(ut_test) then
print_test_elements(treat(a_suite.items(i) as ut_test));
elsif a_suite.items(i) is of(ut_logical_suite) then
print_suite_elements(treat(a_suite.items(i) as ut_logical_suite), a_suite_id);
end if;
end loop;
self.print_text('</testsuite>');
end;
begin
l_suite_id := 0;
self.print_text('<testsuites tests="' || l_tests_count || '"' || self.get_common_item_attributes(a_run) || '>');
for i in 1 .. a_run.items.count loop
print_suite_elements(treat(a_run.items(i) as ut_logical_suite), l_suite_id);
end loop;
self.print_text('</testsuites>');
end;

member function get_common_item_attributes(a_item ut_suite_item) return varchar2 is
begin
return ' skipped="' || a_item.results_count.disabled_count
|| '" error="' || a_item.results_count.errored_count
|| '" failure="' || a_item.results_count.failure_count
|| '" name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name))
|| '" time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '" ';
end;

overriding member function get_description return varchar2 as
begin
return 'Depracated reporter. Please use Junit.
Expand Down
2 changes: 2 additions & 0 deletions test/install_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ whenever oserror exit failure rollback
@@core/test_file_mapper.pks
@@core/test_suite_manager.pks
@@core/test_suite_builder.pks
@@core/reporters.pks
@@core/reporters/test_coverage.pks
set define on
@@install_above_12_1.sql 'core/reporters/test_extended_coverage.pks'
Expand Down Expand Up @@ -69,6 +70,7 @@ set define off
@@core/test_file_mapper.pkb
@@core/test_suite_manager.pkb
@@core/test_suite_builder.pkb
@@core/reporters.pkb
@@core/reporters/test_coverage.pkb
set define on
@@install_above_12_1.sql 'core/reporters/test_extended_coverage.pkb'
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.