Skip to content

Added Support to pass comma delimited list of test names #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions docs/userguide/running-unit-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,26 @@ end;
```
Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_.

```sql
begin
ut.run(ut_varchar2_list('hr.test_apply_bonus,cust)');
end;
```

Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_.

```sql
begin
ut.run('hr.test_apply_bonus,cust');
end;
```

Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_.

Using a list of items to execute allows you to execute a fine-grained set of tests.

List can be passed as a comma separated list or a list of *ut_varchar2_list objects* or as a list within ut_varchar2_list.


**Note:**

Expand Down
11 changes: 8 additions & 3 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ create or replace package body ut_runner is
l_coverage_schema_names ut_varchar2_rows;
l_exclude_object_names ut_object_names := ut_object_names();
l_include_object_names ut_object_names;
l_paths ut_varchar2_list := ut_varchar2_list();
begin
ut_event_manager.initialize();
begin
ut_expectation_processor.reset_invalidation_exception();
ut_utils.save_dbms_output_to_cache();

for i in 1..a_paths.COUNT loop
l_paths := l_paths multiset union ut_utils.string_to_table(a_string => a_paths(i),a_delimiter => ',');
end loop;

ut_console_reporter_base.set_color_enabled(a_color_console);
if a_reporters is null or a_reporters.count = 0 then
ut_event_manager.add_listener(ut_documentation_reporter());
Expand All @@ -107,7 +112,7 @@ create or replace package body ut_runner is
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);
l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths);
end if;

if a_exclude_objects is not empty then
Expand All @@ -119,8 +124,8 @@ create or replace package body ut_runner is
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,
ut_suite_manager.configure_execution_by_path(l_paths),
l_paths,
l_coverage_schema_names,
l_exclude_object_names,
l_include_object_names,
Expand Down
4 changes: 2 additions & 2 deletions test/api/test_ut_run.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ end;]';
begin
execute immediate 'drop package invalid_pckag_that_revalidates';
execute immediate 'drop package parent_specs';
end;

end;
end;
/
2 changes: 1 addition & 1 deletion test/api/test_ut_run.pks
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ create or replace package test_ut_run is
procedure run_and_revalidate_specs;
procedure generate_invalid_spec;
procedure drop_test_package;

end;
/
170 changes: 170 additions & 0 deletions test/api/test_ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,175 @@ end;';
ut.expect(dbms_utility.format_error_stack||dbms_utility.format_error_backtrace).not_to_be_like('%ORA-02055%');
end;

procedure create_test_csl_packages is
pragma autonomous_transaction;
begin
execute immediate q'[
create or replace package test_csl_names1 as
--%suite
--%suitepath(test_csl_names)

--%test
procedure one_is_one;

--%test
procedure two_is_two;

end;
]';

execute immediate q'{
create or replace package body test_csl_names1 as

procedure one_is_one is
begin
ut3.ut.expect(1).to_equal(1);
end;

procedure two_is_two is
begin
ut3.ut.expect(2).to_equal(2);
end;

end;
}';

execute immediate q'[
create or replace package test_csl_names2 as
--%suite
--%suitepath(test_csl_names)

--%test
procedure one_is_one;

--%test
procedure two_is_two;

end;
]';

execute immediate q'{
create or replace package body test_csl_names2 as

procedure one_is_one is
begin
ut3.ut.expect(1).to_equal(1);
end;

procedure two_is_two is
begin
ut3.ut.expect(2).to_equal(2);
end;

end;
}';

end;

procedure drop_test_csl_packages is
pragma autonomous_transaction;
begin
execute immediate 'drop package test_csl_names1';
execute immediate 'drop package test_csl_names2';
end;

procedure pass_varchar2_name_list is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin
select *
bulk collect into l_results
from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2')));

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

procedure pass_varchar2_name is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin
select *
bulk collect into l_results
from table(ut3.ut.run('test_csl_names1'));

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

procedure pass_varchar2_suite_csl is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin
select *
bulk collect into l_results
from table(ut3.ut.run('test_csl_names1,test_csl_names2'));

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

procedure pass_varchar2_test_csl is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin
select *
bulk collect into l_results
from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one'));

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

procedure pass_varch_test_csl_spc is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin
select *
bulk collect into l_results
from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one'));

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

procedure pass_csl_with_srcfile is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin

select *
bulk collect into l_results
from table(
ut3.ut.run(
a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one',
a_source_files => ut3.ut_varchar2_list('ut3.ut'),
a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2')
)
);

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

procedure pass_csl_within_var2list is
l_results ut3.ut_varchar2_list;
l_actual clob;
begin
select *
bulk collect into l_results
from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1.one_is_one,test_csl_names2.one_is_one')));

l_actual := ut3.ut_utils.table_to_clob(l_results);
ut.expect(l_actual).to_be_like('%Finished in % seconds
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
end;

end;
/
30 changes: 30 additions & 0 deletions test/api/test_ut_runner.pks
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,35 @@ create or replace package test_ut_runner is
--%aftertest(db_link_cleanup)
procedure raises_20213_on_fail_link;

procedure create_test_csl_packages;
procedure drop_test_csl_packages;

--%context(ut_run_coma_sep_list)
--%beforeall(create_test_csl_packages)
--%afterall(drop_test_csl_packages)

--%test( Pass name of tests as varchar2_list )
procedure pass_varchar2_name_list;

--%test( Pass single test name as varchar2 )
procedure pass_varchar2_name;

--%test( Pass coma separated list of suite names )
procedure pass_varchar2_suite_csl;

--%test( Pass coma separated list of test names )
procedure pass_varchar2_test_csl;

--%test( Pass coma separated list of test names with spaces )
procedure pass_varch_test_csl_spc;

--%test( Pass coma separated list and source and test files )
procedure pass_csl_with_srcfile;

--%test( Pass coma separated list in varchar2list )
procedure pass_csl_within_var2list;

--%endcontext

end;
/