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
50 commits
Select commit Hold shift + click to select a range
169c7c2
Adding additional installation of utPLSQL framework into schema ut3_r…
jgebal Jul 21, 2017
248b243
Changer install.sh to be runnable from both `sqlplus` and `sqlcl`.
jgebal Jul 22, 2017
c79afbd
Trying to test ut3 using ut3 framework installed in separate schema.
jgebal Jul 23, 2017
adbb543
Testing schema `UT3` with tests in schema `UT3_TESTER` and most recen…
jgebal Jul 28, 2017
746eb07
Moved test_annotations from commit a56231c9b232418f589709d5672c1bee23…
Pazus Jul 30, 2017
fe4b993
actualized ut_utils tests to current state of old tests
Pazus Jul 30, 2017
b7c5917
implemented matcher tests
Pazus Jul 30, 2017
2bde41a
Merge remote-tracking branch 'remotes/upstream/develop' into feature/…
Pazus Jul 30, 2017
74f6bc9
splitted old and new tests
Pazus Jul 30, 2017
266ac1f
added test_output_buffer tests
Pazus Jul 30, 2017
fdc2513
Merge branch 'develop' into feature/using_released_to_test_develop
jgebal Aug 2, 2017
d34c9a6
Updated test script to capture failed tests and return non-zero exit …
jgebal Aug 2, 2017
da01280
Merge remote-tracking branch 'upstream/feature/sonar_test_reporter_fi…
jgebal Aug 3, 2017
1b2dd8c
Enabling tests.
jgebal Aug 3, 2017
cc400cb
Fixing utplsql-cli run invocation.
jgebal Aug 3, 2017
34b94de
Enabling coverage for the framework.
jgebal Aug 3, 2017
e2dccea
Merge branch 'feature/sonar_test_reporter_fix' into feature/using_rel…
jgebal Aug 5, 2017
6155357
Changed the cli call to use doc reporter only once
jgebal Aug 5, 2017
d5abea9
enabled test
Pazus Aug 5, 2017
2155b99
added ut_suite_manager tests
Pazus Aug 5, 2017
37e5533
fixed references in test_suite_manager.pkb
Pazus Aug 5, 2017
adb9320
implemented clone of develop branch
Pazus Aug 5, 2017
c6d482c
simple structure
Pazus Aug 5, 2017
c004cc5
Merge remote-tracking branch 'remotes/upstream/develop' into feature/…
Pazus Aug 5, 2017
e678a4e
change to coverage be run for the main branch not the testing branch
Pazus Aug 5, 2017
4121aaf
changed path to sources
Pazus Aug 6, 2017
33ddecc
Update install_and_run_tests.sh
jgebal Aug 6, 2017
7ba703e
Update ut_sonar_test_reporter.tpb
jgebal Aug 6, 2017
ae9fd09
Update .travis.yml
jgebal Aug 6, 2017
97e408c
Update install_and_run_tests.sh
jgebal Aug 6, 2017
067595f
Update .travis.yml
jgebal Aug 6, 2017
dcce789
Update .travis.yml
jgebal Aug 6, 2017
01691eb
Update install_and_run_tests.sh
jgebal Aug 6, 2017
94cd8c6
Switch to new `utplsql-cli` again
jgebal Aug 6, 2017
bf0bd31
Back to old utlplsq-cli
jgebal Aug 6, 2017
d486456
Testing fix on utPLSQL-cli
viniciusam Aug 7, 2017
c0b1a5f
Testing new client build
viniciusam Aug 7, 2017
8e1ab7c
Added source schema parameter
viniciusam Aug 7, 2017
c2af62a
Adding coveralls reporter to check how coveralls handles multiple cov…
jgebal Aug 7, 2017
9180a2b
Merge branch 'feature/remove_pessimistic_coverage_on_project' into fe…
jgebal Aug 7, 2017
7cf00f0
Renamed `tests` directory to `old_tests`.
jgebal Aug 9, 2017
16e5a06
Disabled test due to failures on US7ASCII code page on 12.1 DB
jgebal Aug 13, 2017
cd0d954
Added test for `ut_coverage_sonar_reporter`
jgebal Aug 13, 2017
b330e74
Added test for `ut_coveralls_reporter`
jgebal Aug 13, 2017
c960d44
Fixed failing tests and refactored sonar reporter.
jgebal Aug 13, 2017
41b4849
Fixed issues with framework accessing wrong tables when running self-…
jgebal Aug 17, 2017
48b6b33
Merge remote-tracking branch 'upstream/develop' into feature/using_re…
jgebal Aug 17, 2017
8badb71
Fixed failing test after rename of `tests` to `old_tests`.
jgebal Aug 17, 2017
57902fc
Merge remote-tracking branch 'upstream/develop' into feature/using_re…
jgebal Aug 18, 2017
ff9865a
Moved new test to the old_tests
jgebal Aug 18, 2017
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
Added test for ut_coverage_sonar_reporter
Added missing privileges to mock data in ut3 schema.
Added ability to mock coverage.
  • Loading branch information
jgebal committed Aug 13, 2017
commit cd0d954f56d8ffbba99bcc7a92ba48fa64036e94
2 changes: 1 addition & 1 deletion .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ set feedback off

set feedback on
--Needed for testing coverage outside of main UT3 schema.
grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, delete any table, create any table, drop any table, alter any table, select any dictionary to $UT3_TESTER;
grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, select any dictionary to $UT3_TESTER;
exit
SQL
31 changes: 21 additions & 10 deletions source/core/coverage/ut_coverage.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ create or replace package body ut_coverage is
limitations under the License.
*/

type t_source_lines is table of binary_integer;

-- The source query has two important transformations done in it.
-- the flag: to_be_skipped ='Y' is set for a line of code that is badly reported by DBMS_PROFILER as executed 0 times.
-- This includes lines that are:
Expand Down Expand Up @@ -157,13 +159,25 @@ create or replace package body ut_coverage is
ut_coverage_helper.coverage_stop_develop();
end;

function get_lines_to_skip(a_object_owner varchar2, a_object_name varchar2) return t_source_lines is
l_result t_source_lines;
begin
select line
bulk collect into l_result
from ut_coverage_sources_tmp o
where to_be_skipped = 'Y'
and o.owner = a_object_owner
and o.name = a_object_name;

return l_result;
end;

function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage is
l_line_calls ut_coverage_helper.unit_line_calls;
l_result t_coverage;
l_new_unit t_unit_coverage;
l_skipped_objects ut_object_names := ut_object_names();

type t_source_lines is table of binary_integer;
l_lines_to_skip t_source_lines;
line_no binary_integer;
begin

Expand All @@ -178,24 +192,21 @@ create or replace package body ut_coverage is
end if;

for src_object in (
select o.owner, o.name, o.full_name, max(o.line) lines_count,
cast(
collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list
) to_be_skipped_list
select o.owner, o.name, o.full_name, max(o.line) lines_count
from ut_coverage_sources_tmp o
group by o.owner, o.name, o.full_name
) loop

l_lines_to_skip := get_lines_to_skip( src_object.owner, src_object.name );

--get coverage data
l_line_calls := ut_coverage_helper.get_raw_coverage_data( src_object.owner, src_object.name );

--if there is coverage, we need to filter out the garbage (badly indicated data from dbms_profiler)
if l_line_calls.count > 0 then
--remove lines that should not be indicted as meaningful
for i in 1 .. src_object.to_be_skipped_list.count loop
if src_object.to_be_skipped_list(i) is not null then
l_line_calls.delete(src_object.to_be_skipped_list(i));
end if;
for i in 1 .. l_lines_to_skip.count loop
l_line_calls.delete(l_lines_to_skip(i));
end loop;
end if;

Expand Down
8 changes: 8 additions & 0 deletions source/core/coverage/ut_coverage_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,13 @@ create or replace package body ut_coverage_helper is
end loop;
return l_results;
end;

procedure mock_coverage_id(a_coverage_id integer) is
begin
if g_develop_mode and g_is_started then
g_coverage_id := a_coverage_id;
end if;
end;

end;
/
6 changes: 6 additions & 0 deletions source/core/coverage/ut_coverage_helper.pks
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,11 @@ create or replace package ut_coverage_helper authid definer is
procedure coverage_resume;

function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2) return unit_line_calls;

/***
* Allows overwriting of private global variable g_coverage_id
* Used internally, only for unit testing of the framework only
*/
procedure mock_coverage_id(a_coverage_id integer);
end;
/
84 changes: 84 additions & 0 deletions test/ut_reporters/test_coverage.pkb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
create or replace package body test_coverage is

g_run_id integer;

function get_mock_run_id return integer is
v_result integer;
begin
select min(runid) - 1 into v_result
from ut3.plsql_profiler_runs;
return v_result;
end;

procedure create_dummy_coverage_package is
begin
execute immediate q'[create or replace package DUMMY_COVERAGE is
procedure do_stuff;
end;]';
execute immediate q'[create or replace package body DUMMY_COVERAGE is
procedure do_stuff is
begin
if 1 = 2 then
dbms_output.put_line('should not get here');
else
dbms_output.put_line('should get here');
end if;
end;
end;]';
end;

procedure create_dummy_coverage_test is
begin
execute immediate q'[create or replace package TEST_DUMMY_COVERAGE is
--%suite(dummy coverage test)

--%test
procedure test_do_stuff;
end;]';
execute immediate q'[create or replace package body TEST_DUMMY_COVERAGE is
procedure test_do_stuff is
begin
dummy_coverage.do_stuff;
end;
end;]';
end;

procedure mock_coverage_data(a_run_id integer) is
c_unit_id constant integer := 1;
begin
insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment)
values(a_run_id, user, sysdate, 'unit testing utPLSQL');

insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name)
values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3_TESTER', 'DUMMY_COVERAGE');

insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time)
select a_run_id, c_unit_id, 4, 1, 1 from dual union all
select a_run_id, c_unit_id, 5, 0, 0 from dual union all
select a_run_id, c_unit_id, 7, 1, 1 from dual;
end;

procedure setup_dummy_coverage is
pragma autonomous_transaction;
begin
create_dummy_coverage_package();
create_dummy_coverage_test();
g_run_id := get_mock_run_id();
ut3.ut_coverage_helper.mock_coverage_id(g_run_id);
mock_coverage_data(g_run_id);
commit;
end;

procedure cleanup_dummy_coverage is
pragma autonomous_transaction;
begin
execute immediate q'[drop package test_dummy_coverage]';
execute immediate q'[drop package dummy_coverage]';
delete from ut3.plsql_profiler_data where runid = g_run_id;
delete from ut3.plsql_profiler_units where runid = g_run_id;
delete from ut3.plsql_profiler_runs where runid = g_run_id;
commit;
end;

end;
/
13 changes: 13 additions & 0 deletions test/ut_reporters/test_coverage.pks
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
create or replace package test_coverage is

--%suite
--%suitepath(utplsql.core)

--%beforeall
procedure setup_dummy_coverage;

--%afterall
procedure cleanup_dummy_coverage;

end;
/
34 changes: 34 additions & 0 deletions test/ut_reporters/test_coverage_sonar_reporter.pkb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
create or replace package body test_coverage_sonar_reporter is

procedure report_on_file is
v_run_id integer;
l_results ut3.ut_varchar2_list;
l_expected clob;
l_actual clob;
begin
--Arrange
l_expected := '<coverage version="1">
<file path="test/dummy_coverage.pkb">
<lineToCover lineNumber="4" covered="true"/>
<lineToCover lineNumber="5" covered="false"/>
<lineToCover lineNumber="7" covered="true"/>
</file>
</coverage>';
--Act
select *
bulk collect into l_results
from table(
ut3.ut.run(
a_path => 'test_dummy_coverage',
a_reporter=> ut3.ut_coverage_sonar_reporter( ),
a_source_files => ut3.ut_varchar2_list( 'test/dummy_coverage.pkb' ),
a_test_files => ut3.ut_varchar2_list( )
)
);
l_actual := ut3.ut_utils.table_to_clob(l_results);
--Assert
ut.expect(l_actual).to_equal(l_expected);
end;

end;
/
10 changes: 10 additions & 0 deletions test/ut_reporters/test_coverage_sonar_reporter.pks
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
create or replace package test_coverage_sonar_reporter is

--%suite(ut_coverge_sonar_reporter)
--%suitepath(utplsql.core.test_coverage.reporters)

--%test(reports on a project file mapped to database object)
procedure report_on_file;

end;
/