diff --git a/examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql b/examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql index 8b221a941..be04c814e 100644 --- a/examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql +++ b/examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql @@ -19,17 +19,17 @@ declare testtoexecute ut_test; reporter ut_reporter; begin - suite1 := ut_test_suite(a_suite_name => 'Test Suite 1' /*,a_items => ut_test_objects_list()*/); + suite1 := ut_test_suite(a_suite_name => 'Test Suite 1', a_object_name => null /*,a_items => ut_test_objects_list()*/); testtoexecute := ut_test(a_object_name => 'ut_exampletest' ,a_test_procedure => 'ut_exAmpletest' - ,a_test_name => 'Example test1' + ,a_test_name => 'Example test1' ,a_setup_procedure => 'Setup' ,a_teardown_procedure => 'tEardown'); suite1.add_item(testtoexecute); - suite2 := ut_test_suite(a_suite_name => 'Test Suite 2' /*,a_items => ut_test_objects_list()*/); + suite2 := ut_test_suite(a_suite_name => 'Test Suite 2', a_object_name => null /*,a_items => ut_test_objects_list()*/); testtoexecute := ut_test(a_object_name => 'UT_EXAMPLETEST2' ,a_test_procedure => 'UT_EXAMPLETEST' ,a_setup_procedure => 'SETUP' @@ -37,7 +37,7 @@ begin suite2.add_item(testtoexecute); - suite_complex := ut_test_suite(a_suite_name => 'Complex Test Suite', a_items => ut_objects_list(suite1, suite2)); + suite_complex := ut_test_suite(a_suite_name => 'Complex Test Suite', a_object_name => null, a_items => ut_objects_list(suite1, suite2)); -- provide a reporter to process results reporter := ut_custom_reporter(a_tab_size => 2); diff --git a/examples/RunExampleTestSuite.sql b/examples/RunExampleTestSuite.sql index e6764e10c..b58380130 100644 --- a/examples/RunExampleTestSuite.sql +++ b/examples/RunExampleTestSuite.sql @@ -16,7 +16,7 @@ declare test_item ut_test; assert ut_assert_result; begin - suite := ut_test_suite(a_suite_name => 'Test Suite Name' /*,a_items => ut_test_objects_list()*/); + suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/); testtoexecute := ut_test(a_object_name => 'ut_exampletest' ,a_test_procedure => 'ut_exAmpletest' diff --git a/examples/RunExampleTestSuiteWithCompositeReporter.sql b/examples/RunExampleTestSuiteWithCompositeReporter.sql index 146e59b40..52de42841 100644 --- a/examples/RunExampleTestSuiteWithCompositeReporter.sql +++ b/examples/RunExampleTestSuiteWithCompositeReporter.sql @@ -16,7 +16,7 @@ declare testtoexecute ut_test; reporter ut_reporter; begin - suite := ut_test_suite(a_suite_name => 'Test Suite Name' /*,a_items => ut_test_objects_list()*/); + suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/); testtoexecute := ut_test(a_object_name => 'ut_exampletest' ,a_test_procedure => 'ut_exAmpletest' diff --git a/examples/RunExampleTestSuiteWithCustomDBMSOutputReporter.sql b/examples/RunExampleTestSuiteWithCustomDBMSOutputReporter.sql index 3e7359bde..6624a6069 100644 --- a/examples/RunExampleTestSuiteWithCustomDBMSOutputReporter.sql +++ b/examples/RunExampleTestSuiteWithCustomDBMSOutputReporter.sql @@ -20,7 +20,7 @@ declare begin -- Install ut_custom_reporter first from example folder - suite := ut_test_suite(a_suite_name => 'Test Suite Name' /*,a_items => ut_test_objects_list()*/); + suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/); testtoexecute := ut_test(a_object_name => 'ut_exampletest' ,a_test_procedure => 'ut_exAmpletest' diff --git a/examples/RunExampleTestSuiteWithDBMSOutputReporter.sql b/examples/RunExampleTestSuiteWithDBMSOutputReporter.sql index 39d828a59..ee045bc13 100644 --- a/examples/RunExampleTestSuiteWithDBMSOutputReporter.sql +++ b/examples/RunExampleTestSuiteWithDBMSOutputReporter.sql @@ -15,7 +15,7 @@ declare testtoexecute ut_test; reporter ut_reporter; begin - suite := ut_test_suite(a_suite_name => 'Test Suite Name' /*,a_items => ut_test_objects_list()*/); + suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/); testtoexecute := ut_test(a_object_name => 'ut_exampletest' ,a_test_procedure => 'ut_exAmpletest' diff --git a/examples/test_pkg1.pck b/examples/test_pkg1.pck index 6894e0f77..19e4f8b63 100644 --- a/examples/test_pkg1.pck +++ b/examples/test_pkg1.pck @@ -65,13 +65,13 @@ create or replace package body test_pkg1 is procedure test1 is begin + ut.expect(g_val1,'1 equals 1 check').to_equal(1); ut_assert.are_equal(a_msg => '1 equals 1 check', a_expected => 1, a_actual => g_val1); end; procedure test2 is begin - --ut_assert.are_equal(a_msg => 'null equals null check', a_expected => to_number(null), a_actual => g_val1); - ut_assert.are_equal(a_msg => '2 equals 2 check', a_expected => 2, a_actual => g_val2); + ut.expect(g_val2,'2 equals 2 check').to_equal(2); end; procedure global_setup is diff --git a/examples/test_pkg2.pck b/examples/test_pkg2.pck index c45200f4e..2438a14f4 100644 --- a/examples/test_pkg2.pck +++ b/examples/test_pkg2.pck @@ -18,12 +18,12 @@ create or replace package body test_pkg2 is procedure test1 is begin - ut_assert.are_equal(a_msg => '1 equals 1 check', a_expected => 1, a_actual => 1); + ut.expect(1,'1 equals 1 check').to_equal(1); end; procedure test2 is begin - ut_assert.are_equal(a_msg => '2 equals 2 check', a_expected => 2, a_actual => 2); + ut.expect(2,'2 equals 2 check').to_equal(2); end; end test_pkg2; diff --git a/source/core/types/ut_test.tpb b/source/core/types/ut_test.tpb index c9bbe2108..d2e0c22a8 100644 --- a/source/core/types/ut_test.tpb +++ b/source/core/types/ut_test.tpb @@ -1,11 +1,16 @@ create or replace type body ut_test is - constructor function ut_test(self in out nocopy ut_test,a_object_name varchar2, a_test_procedure varchar2, a_test_name in varchar2 default null, a_owner_name varchar2 default null, a_setup_procedure varchar2 default null, a_teardown_procedure varchar2 default null, a_rollback_type integer default null) + constructor function ut_test(self in out nocopy ut_test,a_object_name varchar2,a_object_path varchar2 default null, a_test_procedure varchar2, a_test_name in varchar2 default null, a_owner_name varchar2 default null, a_setup_procedure varchar2 default null, a_teardown_procedure varchar2 default null, a_rollback_type integer default null) return self as result is begin - self.name := a_test_name; + + self.init(a_desc_name => a_test_name + ,a_object_name => a_test_procedure + ,a_object_type => 1 + ,a_object_path => a_object_path + ,a_rollback_type => a_rollback_type); + self.object_type := 1; - self.object_name := lower(trim(a_test_procedure)); self.test := ut_executable(object_name => trim(a_object_name) ,procedure_name => trim(a_test_procedure) ,owner_name => trim(a_owner_name)); @@ -22,12 +27,6 @@ create or replace type body ut_test is ,owner_name => trim(a_owner_name)); end if; - if a_rollback_type is not null then - ut_utils.validate_rollback_type(a_rollback_type); - self.rollback_type := a_rollback_type; - else - self.rollback_type := ut_utils.gc_rollback_auto; - end if; return; end ut_test; diff --git a/source/core/types/ut_test.tps b/source/core/types/ut_test.tps index 071032573..d977ea954 100644 --- a/source/core/types/ut_test.tps +++ b/source/core/types/ut_test.tps @@ -4,7 +4,7 @@ create or replace type ut_test force under ut_test_object test ut_executable, teardown ut_executable, - constructor function ut_test(self in out nocopy ut_test,a_object_name varchar2, a_test_procedure varchar2, a_test_name in varchar2 default null, a_owner_name varchar2 default null, a_setup_procedure varchar2 default null, a_teardown_procedure varchar2 default null, a_rollback_type integer default null) + constructor function ut_test(self in out nocopy ut_test,a_object_name varchar2,a_object_path varchar2 default null, a_test_procedure varchar2, a_test_name in varchar2 default null, a_owner_name varchar2 default null, a_setup_procedure varchar2 default null, a_teardown_procedure varchar2 default null, a_rollback_type integer default null) return self as result, member function is_valid return boolean, diff --git a/source/core/types/ut_test_object.tpb b/source/core/types/ut_test_object.tpb index 269da4ff1..d51ff0759 100644 --- a/source/core/types/ut_test_object.tpb +++ b/source/core/types/ut_test_object.tpb @@ -1,4 +1,20 @@ create or replace type body ut_test_object is + + member procedure init(self in out nocopy ut_test_object, a_desc_name varchar2, a_object_name varchar2, a_object_type integer, a_object_path varchar2 default null, a_rollback_type integer default null) is + begin + self.name := a_desc_name; + self.object_type := a_object_type; + self.object_name := lower(trim(a_object_name)); + self.object_path := nvl(lower(trim(a_object_path)), self.object_name); + + if a_rollback_type is not null then + ut_utils.validate_rollback_type(a_rollback_type); + self.rollback_type := a_rollback_type; + else + self.rollback_type := ut_utils.gc_rollback_auto; + end if; + return; + end; member procedure set_ignore_flag(self in out nocopy ut_test_object, a_ignore_flag boolean) is begin diff --git a/source/core/types/ut_test_object.tps b/source/core/types/ut_test_object.tps index 34801f9f7..fb343904d 100644 --- a/source/core/types/ut_test_object.tps +++ b/source/core/types/ut_test_object.tps @@ -1,10 +1,14 @@ create or replace type ut_test_object force under ut_composite_object ( - start_time timestamp with time zone, - end_time timestamp with time zone, + object_name varchar2(4000), + object_path varchar2(4000), rollback_type integer(1), -- ut_utils:gc_rollback_% constants ignore_flag integer(1), + start_time timestamp with time zone, + end_time timestamp with time zone, + + member procedure init(self in out nocopy ut_test_object, a_desc_name varchar2, a_object_name varchar2, a_object_type integer, a_object_path varchar2 default null, a_rollback_type integer default null), not instantiable member procedure do_execute(self in out nocopy ut_test_object, a_reporter in out nocopy ut_reporter), final member procedure do_execute(self in out nocopy ut_test_object), diff --git a/source/core/types/ut_test_suite.tpb b/source/core/types/ut_test_suite.tpb index 3e450c522..e2ecdebd5 100644 --- a/source/core/types/ut_test_suite.tpb +++ b/source/core/types/ut_test_suite.tpb @@ -1,20 +1,17 @@ create or replace type body ut_test_suite is - constructor function ut_test_suite(self in out nocopy ut_test_suite,a_suite_name varchar2, a_object_name varchar2 default null, a_items ut_objects_list default ut_objects_list(), a_rollback_type number default null) + constructor function ut_test_suite (self in out nocopy ut_test_suite, a_suite_name varchar2, a_object_name varchar2, a_object_path varchar2 default null, a_items ut_objects_list default ut_objects_list(), a_rollback_type number default null) return self as result is begin - self.name := a_suite_name; - self.object_type := 2; - self.items := a_items; - self.object_name := lower(trim(a_object_name)); - - if a_rollback_type is not null then - ut_utils.validate_rollback_type(a_rollback_type); - self.rollback_type := a_rollback_type; - else - self.rollback_type := ut_utils.gc_rollback_auto; - end if; + self.init(a_desc_name => a_suite_name + ,a_object_name => a_object_name + ,a_object_type => 2 + ,a_object_path => a_object_path + ,a_rollback_type => a_rollback_type); + + self.items := a_items; + return; end ut_test_suite; @@ -43,37 +40,37 @@ create or replace type body ut_test_suite is overriding member procedure do_execute(self in out nocopy ut_test_suite, a_reporter in out nocopy ut_reporter) is l_test_object ut_test_object; - l_savepoint varchar2(30); + l_savepoint varchar2(30); begin a_reporter.before_suite(self); ut_utils.debug_log('ut_test_suite.execute'); - + self.start_time := current_timestamp; - + if self.ignore_flag = 1 then self.result := ut_utils.tr_ignore; elsif self.is_valid() then - + if self.rollback_type = ut_utils.gc_rollback_auto then l_savepoint := ut_utils.gen_savepoint_name; execute immediate 'savepoint ' || l_savepoint; end if; if self.setup is not null then - a_reporter.before_suite_setup(self); + a_reporter.before_suite_setup(self); self.setup.do_execute; a_reporter.after_suite_setup(self); end if; for i in self.items.first .. self.items.last loop - a_reporter.before_suite_item(a_suite => self,a_item_index => i); - + a_reporter.before_suite_item(a_suite => self, a_item_index => i); + l_test_object := treat(self.items(i) as ut_test_object); l_test_object.do_execute(a_reporter => a_reporter); self.items(i) := l_test_object; - - a_reporter.after_suite_item(a_suite => self,a_item_index => i); + + a_reporter.after_suite_item(a_suite => self, a_item_index => i); end loop; if self.teardown is not null then @@ -83,7 +80,7 @@ create or replace type body ut_test_suite is end if; self.calc_execution_result; - + if self.rollback_type = ut_utils.gc_rollback_auto then execute immediate 'rollback to ' || l_savepoint; end if; diff --git a/source/core/types/ut_test_suite.tps b/source/core/types/ut_test_suite.tps index 53972b7dc..eb903bd8d 100644 --- a/source/core/types/ut_test_suite.tps +++ b/source/core/types/ut_test_suite.tps @@ -4,7 +4,7 @@ create or replace type ut_test_suite force under ut_test_object setup ut_executable, teardown ut_executable, - constructor function ut_test_suite(self in out nocopy ut_test_suite,a_suite_name varchar2, a_object_name varchar2 default null, a_items ut_objects_list default ut_objects_list(), a_rollback_type number default null) + constructor function ut_test_suite(self in out nocopy ut_test_suite,a_suite_name varchar2, a_object_name varchar2, a_object_path varchar2 default null, a_items ut_objects_list default ut_objects_list(), a_rollback_type number default null) return self as result, member procedure set_suite_setup (self in out nocopy ut_test_suite, a_object_name in varchar2, a_proc_name in varchar2, a_owner_name varchar2 default null), diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 347357ea6..843880816 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -23,13 +23,13 @@ create or replace package body ut_suite_manager is l_suite_teardown_proc varchar2(32 char); l_suite_package varchar2(4000 char); - l_proc_name ut_annotations.t_procedure_name; + l_proc_name ut_annotations.t_procedure_name; l_owner_name varchar2(32 char); l_object_name varchar2(32 char); l_suite ut_test_suite; - - l_suite_rollback integer; + + l_suite_rollback integer; l_suite_rollback_annotation varchar2(4000); begin @@ -46,26 +46,28 @@ create or replace package body ut_suite_manager is if l_annotation_data.package_annotations.exists('suitepackage') then l_suite_package := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('suitepackage'), 1) || '.' || lower(l_object_name); - else - l_suite_package := lower(l_object_name); end if; - + if l_annotation_data.package_annotations.exists('rollback') then - l_suite_rollback_annotation := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('rollback'), 1); - l_suite_rollback := case lower(l_suite_rollback_annotation) - when 'manual' then - ut_utils.gc_rollback_manual - when 'auto' then - ut_utils.gc_rollback_auto - else - ut_utils.gc_rollback_auto - end; + l_suite_rollback_annotation := ut_annotations.get_annotation_param(l_annotation_data.package_annotations('rollback') + ,1); + l_suite_rollback := case lower(l_suite_rollback_annotation) + when 'manual' then + ut_utils.gc_rollback_manual + when 'auto' then + ut_utils.gc_rollback_auto + else + ut_utils.gc_rollback_auto + end; else l_suite_rollback := ut_utils.gc_rollback_auto; end if; - - l_suite := ut_test_suite(l_suite_name, l_suite_package, a_rollback_type => l_suite_rollback); - + + l_suite := ut_test_suite(a_suite_name => l_suite_name + ,a_object_name => l_object_name + ,a_object_path => l_suite_package + ,a_rollback_type => l_suite_rollback); + if l_annotation_data.package_annotations.exists('ignore') then l_suite.set_ignore_flag(true); end if; @@ -102,7 +104,7 @@ create or replace package body ut_suite_manager is l_proc_name := l_annotation_data.procedure_annotations.first; while l_proc_name is not null loop - + l_proc_annotations := l_annotation_data.procedure_annotations(l_proc_name); if l_proc_annotations.exists('test') then declare @@ -118,29 +120,30 @@ create or replace package body ut_suite_manager is if l_proc_annotations.exists('testteardown') then l_teardown_procedure := ut_annotations.get_annotation_param(l_proc_annotations('testteardown'), 1); end if; - + if l_proc_annotations.exists('rollback') then l_rollback_annotation := ut_annotations.get_annotation_param(l_proc_annotations('rollback'), 1); - l_rollback_type := case lower(l_rollback_annotation) - when 'manual' then - ut_utils.gc_rollback_manual - when 'auto' then - ut_utils.gc_rollback_auto - --when 'on-error' then - -- ut_utils.gc_rollback_on_error - else - l_suite_rollback - end; + l_rollback_type := case lower(l_rollback_annotation) + when 'manual' then + ut_utils.gc_rollback_manual + when 'auto' then + ut_utils.gc_rollback_auto + --when 'on-error' then + -- ut_utils.gc_rollback_on_error + else + l_suite_rollback + end; end if; l_test := ut_test(a_object_name => l_object_name + ,a_object_path => l_suite.object_path || '.' || l_proc_name ,a_test_procedure => l_proc_name ,a_test_name => ut_annotations.get_annotation_param(l_proc_annotations('test'), 1) ,a_owner_name => l_owner_name ,a_setup_procedure => nvl(l_setup_procedure, l_default_setup_proc) ,a_teardown_procedure => nvl(l_teardown_procedure, l_default_teardown_proc) ,a_rollback_type => l_rollback_type); - + if l_proc_annotations.exists('ignore') then l_test.set_ignore_flag(true); end if; @@ -148,16 +151,16 @@ create or replace package body ut_suite_manager is l_suite.add_item(l_test); end; end if; - + l_proc_name := l_annotation_data.procedure_annotations.next(l_proc_name); end loop; end if; return l_suite; - + end config_package; procedure config_schema(a_owner_name varchar2) is - l_suite ut_test_suite; + l_suite ut_test_suite; l_all_suites tt_schema_suits; l_ind varchar2(4000 char); @@ -167,25 +170,29 @@ create or replace package body ut_suite_manager is l_schema_suites tt_schema_suits; - procedure put(a_root_suite in out nocopy ut_test_suite, a_path varchar2, a_suite ut_test_suite) is + procedure put(a_root_suite in out nocopy ut_test_suite, a_path varchar2, a_suite ut_test_suite, a_parent_path varchar2 default null) is l_temp_root varchar2(4000 char); + l_path varchar2(4000 char); l_cur_item ut_test_suite; l_ind pls_integer; begin if a_path like '%.%' then l_temp_root := regexp_substr(a_path, '^[^.]+'); + l_path := ltrim(a_parent_path||'.'||l_temp_root,'.'); if a_root_suite is not null then l_ind := a_root_suite.item_index(l_temp_root); if l_ind is null then - l_cur_item := ut_test_suite(null, l_temp_root); + l_cur_item := ut_test_suite(a_suite_name => null + ,a_object_name => l_temp_root + ,a_object_path => l_path); else l_cur_item := treat(a_root_suite.items(l_ind) as ut_test_suite); end if; - put(l_cur_item, trim_path(a_path, l_temp_root || '.'), a_suite); + put(l_cur_item, trim_path(a_path, l_temp_root || '.'), a_suite, l_path); if l_ind is null then a_root_suite.add_item(l_cur_item); @@ -194,8 +201,10 @@ create or replace package body ut_suite_manager is end if; else - a_root_suite := ut_test_suite(null, l_temp_root); - put(a_root_suite, trim_path(a_path, l_temp_root || '.'), a_suite); + a_root_suite := ut_test_suite(a_suite_name => null + ,a_object_name => l_temp_root + ,a_object_path => l_path); + put(a_root_suite, trim_path(a_path, l_temp_root || '.'), a_suite, l_path); end if; else if a_root_suite is not null then @@ -210,7 +219,7 @@ create or replace package body ut_suite_manager is procedure print(a_suite ut_test_suite, a_pad pls_integer) is l_test ut_test; begin - dbms_output.put_line(lpad(' ', a_pad, ' ') || 'Suite: ' || a_suite.object_name); + dbms_output.put_line(lpad(' ', a_pad, ' ') || 'Suite: ' || a_suite.object_name||'('||a_suite.object_path||')'); dbms_output.put_line(lpad(' ', a_pad, ' ') || 'Items: '); for i in 1 .. a_suite.items.count loop if a_suite.items(i) is of(ut_test_suite) then @@ -218,7 +227,7 @@ create or replace package body ut_suite_manager is else l_test := treat(a_suite.items(i) as ut_test); - dbms_output.put_line(lpad(' ', a_pad + 2, ' ') || 'Test: ' || l_test.object_name); + dbms_output.put_line(lpad(' ', a_pad + 2, ' ') || 'Test: ' || l_test.object_name||'('||l_test.object_path||')'); end if; end loop; end print; @@ -235,7 +244,7 @@ create or replace package body ut_suite_manager is l_suite := config_package(rec.owner, rec.object_name); if l_suite is not null then - l_all_suites(l_suite.object_name) := l_suite; + l_all_suites(l_suite.object_path) := l_suite; end if; end loop; @@ -328,5 +337,175 @@ create or replace package body ut_suite_manager is run_schema_suites(sys_context('userenv', 'current_schema'), l_temp_reported, a_force_parse_again); end run_cur_schema_suites_static; + function get_schema_suites(a_schema_name in varchar2) return tt_schema_suits is + begin + -- Currently cache invalidation on DDL is not implemented so schema is rescaned each time + --if not g_schema_suites.exists(a_schema_name) then + -- config_schema(a_schema_name); + --end if; + config_schema(a_schema_name); + + return g_schema_suites(a_schema_name); + end get_schema_suites; + + -- Validate all paths are correctly formatted + procedure validate_paths(a_paths in ut_varchar2_list) is + l_path varchar2(32767); + begin + if a_paths is null or a_paths.count = 0 then + raise_application_error(ut_utils.gc_path_list_is_empty, 'Path list is empty'); + else + for i in 1 .. a_paths.count loop + l_path := a_paths(i); + if l_path is null or not (regexp_like(l_path, '^\w+(\.\w+){0,2}$') or regexp_like(l_path, '^\w+:\w+(\.\w+)*$')) then + raise_application_error(ut_utils.gc_invalid_path_format, 'Invalid path format: ' || nvl(l_path, 'NULL')); + end if; + end loop; + end if; + end validate_paths; + + procedure configure_execution_by_path(a_paths in ut_varchar2_list, a_objects_to_run out nocopy ut_objects_list) is + l_paths ut_varchar2_list; + l_path varchar2(32767); + l_schema varchar2(4000); + l_schema_suites tt_schema_suits; + l_index varchar2(4000 char); + l_suite ut_test_suite; + l_suite_path varchar2(4000); + l_root_suite_name varchar2(4000); + + function clean_paths(a_paths ut_varchar2_list) return ut_varchar2_list is + l_paths ut_varchar2_list := ut_varchar2_list(); + begin + l_paths.extend(a_paths.count); + for i in 1 .. a_paths.count loop + l_paths(i) := trim(lower(a_paths(i))); + end loop; + l_paths := set(l_paths); + return l_paths; + end clean_paths; + + procedure skip_by_path(a_suite in out nocopy ut_test_object, a_path varchar2) is + l_root constant varchar2(32767) := regexp_substr(a_path, '\w+'); + l_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1); + l_item ut_test_object; + l_items ut_objects_list := ut_objects_list(); + l_object_name varchar2(32767); + + begin + a_suite.set_ignore_flag(false); + + if a_path is not null then + + for i in 1 .. a_suite.items.count loop + + l_item := treat(a_suite.items(i) as ut_test_object); + + l_object_name := l_item.object_name; + --l_object_name := regexp_substr(l_object_name,'\w+$'); -- temporary fix. seems like suite have suitepath in object_name + if regexp_like(l_object_name, l_root, modifier => 'i') then + + skip_by_path(l_item, l_rest_path); + l_items.extend; + l_items(l_items.count) := l_item; + + end if; + + end loop; + + a_suite.items := l_items; + + if l_items.count = 0 then--not l_found then + raise_application_error(-20203, 'Suite note found'); + end if; + end if; + end skip_by_path; + + begin + l_paths := clean_paths(a_paths); + + validate_paths(l_paths); + a_objects_to_run := ut_objects_list(); + + -- current implementation operates only on a single path + -- to be improved later + for i in 1 .. l_paths.count loop + l_path := l_paths(i); + l_schema := regexp_substr(l_path, '^(\w+)(\.|:|$)', 1, 1, null, 1); + + l_schema_suites := get_schema_suites(upper(l_schema)); + + if regexp_like(l_path, '^\w+$') then + -- run whole schema + l_index := l_schema_suites.first; + while l_index is not null loop + a_objects_to_run.extend; + a_objects_to_run(a_objects_to_run.count) := l_schema_suites(l_index); + l_index := l_schema_suites.next(l_index); + end loop; + else + -- convert SCHEMA.PACKAGE.PROCEDURE syntax to fully qualified path + if regexp_like(l_path, '^\w+(\.\w+){1,2}$') then + declare + l_temp_suite ut_test_suite; + l_package_name varchar2(4000); + l_procedure_name varchar2(4000); + begin + l_package_name := regexp_substr(l_path, '^\w+\.(\w+)(\.(\w+))?$', subexpression => 1); + l_procedure_name := regexp_substr(l_path, '^\w+\.(\w+)(\.(\w+))?$', subexpression => 3); + + l_temp_suite := config_package(l_schema, l_package_name); + l_path := rtrim(l_schema || ':' || l_temp_suite.object_path || '.' || l_procedure_name, '.'); + end; + end if; + + -- fully quilified path branch in the form + -- by this time it's the only format left + -- schema:suite.suite.suite + l_suite_path := regexp_substr(l_path, ':(.+)', subexpression => 1); + l_root_suite_name := regexp_substr(l_suite_path, '^\w+'); + + begin + l_suite := l_schema_suites(l_root_suite_name); + exception when no_data_found then + raise_application_error(-20203, 'Suite ' || l_root_suite_name || ' note found'); + end; + + skip_by_path(l_suite, regexp_substr(l_suite_path, '\.(.+)', subexpression => 1)); + + a_objects_to_run.extend; + a_objects_to_run(a_objects_to_run.count) := l_suite; + + end if; + + end loop; + end configure_execution_by_path; + + procedure run(a_paths in ut_varchar2_list, a_reporter in ut_reporter) is + l_objects_to_run ut_objects_list; + l_reporter ut_reporter := a_reporter; + ut_running_suite ut_test_suite; + begin + configure_execution_by_path(a_paths,l_objects_to_run); + + if l_objects_to_run.count > 0 then + l_reporter.before_run(a_suites => l_objects_to_run); + for i in 1 .. l_objects_to_run.count loop + + ut_running_suite := treat(l_objects_to_run(i) as ut_test_suite); + ut_running_suite.do_execute(l_reporter); + l_objects_to_run(i) := ut_running_suite; + + end loop; + l_reporter.after_run(a_suites => l_objects_to_run); + end if; + end; + + + procedure run(a_path in varchar2, a_reporter in ut_reporter) is + begin + run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporter); + end run; + end ut_suite_manager; / diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks index aec997781..5eb8c8144 100644 --- a/source/core/ut_suite_manager.pks +++ b/source/core/ut_suite_manager.pks @@ -11,6 +11,13 @@ create or replace package ut_suite_manager authid definer is procedure run_cur_schema_suites(a_reporter in out nocopy ut_reporter, a_force_parse_again boolean default false); procedure run_cur_schema_suites_static(a_reporter in ut_reporter, a_force_parse_again boolean default false); + + procedure run(a_path in varchar2, a_reporter in ut_reporter); + -- to be implemented + --procedure run(a_paths in ut_varchar2_list, a_reporter in ut_reporter); + + --INTERNAL USE + procedure configure_execution_by_path(a_paths in ut_varchar2_list, a_objects_to_run out nocopy ut_objects_list); end ut_suite_manager; / diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 44574574b..714b98e77 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -6,11 +6,8 @@ create or replace package ut_utils authid definer is */ - /* Constants: Test Results - tr_success - test passed - tr_failure - one or more asserts failed - tr_error - exception was raised - */ + /* Constants: Test Results */ + tr_skip constant number(1) := -1; -- silent skip without reporting. internal use tr_ignore constant number(1) := 0; -- test/suite was ignored tr_success constant number(1) := 1; -- test passed tr_failure constant number(1) := 2; -- one or more asserts failed @@ -28,8 +25,18 @@ create or replace package ut_utils authid definer is gc_rollback_manual constant number(1) := 1; -- leave transaction control manual --gc_rollback_on_error constant number(1) := 2; -- rollback tests only on error - ex_unsopported_rollback_type exception; - pragma exception_init(ex_unsopported_rollback_type, -20200); + ex_unsupported_rollback_type exception; + gc_unsupported_rollback_type constant pls_integer := -20200; + pragma exception_init(ex_unsupported_rollback_type, -20200); + + ex_path_list_is_empty exception; + gc_path_list_is_empty constant pls_integer := -20201; + pragma exception_init(ex_path_list_is_empty, -20201); + + ex_invalid_path_format exception; + gc_invalid_path_format constant pls_integer := -20202; + pragma exception_init(ex_invalid_path_format, -20202); + gc_max_output_string_length constant integer := 4000; gc_max_input_string_length constant integer := gc_max_output_string_length - 2; --we need to remove 2 chars for quotes around string diff --git a/source/expectations/ut.pkb b/source/expectations/ut.pkb index a64dcd66b..86f0377db 100644 --- a/source/expectations/ut.pkb +++ b/source/expectations/ut.pkb @@ -1,5 +1,10 @@ create or replace package body ut is + procedure run(a_path in varchar2, a_reporter in ut_reporter) is + begin + ut_suite_manager.run(a_path, a_reporter); + end; + function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_anydata is begin return ut_expectation_anydata(ut_data_value_anydata(a_actual), a_message); diff --git a/source/expectations/ut.pks b/source/expectations/ut.pks index d65f351bb..5e28e97c1 100644 --- a/source/expectations/ut.pks +++ b/source/expectations/ut.pks @@ -1,5 +1,20 @@ create or replace package ut authid current_user as + /** + * Run suites/tests by path + * Accepts value of the following formats: + * schema - executes all suites in the schema + * schema:suite1[.suite2] - executes all items of suite1 (suite2) in the schema. + * suite1.suite2 is a suitepath variable + * schema:suite1[.suite2][.test1] - executes test1 in suite suite1.suite2 + * schema.suite1 - executes the suite package suite1 in the schema "schema" + * all the parent suites in the hiearcy setups/teardown procedures as also executed + * all chile items are executed + * schema.suite1.test2 - executes test2 procedure of suite1 suite with execution of all + * parent setup/teardown procedures + */ + procedure run(a_path in varchar2, a_reporter in ut_reporter); + function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_anydata; function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation_blob; diff --git a/tests/RunAll.sql b/tests/RunAll.sql index 275297559..c9c572d3d 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -15,6 +15,9 @@ set serveroutput on size unlimited format truncated create table ut$test_table (val varchar2(1)); @@helpers/ut_transaction_control.pck @@helpers/department.tps +@@helpers/test_package_3.pck +@@helpers/test_package_1.pck +@@helpers/test_package_2.pck --Tests to invoke @@ -160,6 +163,16 @@ create table ut$test_table (val varchar2(1)); @@lib/RunTest.sql ut_utils/ut_utils.to_string.verySmallNumber.sql @@ut_utils/ut_utils.clob_to_table.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql +@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql + @@lib/RunTest.sql ut_output_dbms_pipe/ut_output_dbms_pipe.close.TimesOutAfterAGivenPeriodOfTimeAndRemovesPipe.sql @@lib/RunTest.sql ut_output_dbms_pipe/ut_output_dbms_pipe.get_clob_lines.ReturnsSentLines.sql @@lib/RunTest.sql ut_output_dbms_pipe/ut_output_dbms_pipe.get_lines.ReturnsSentLines.sql @@ -171,12 +184,16 @@ create table ut$test_table (val varchar2(1)); @@lib/RunTest.sql ut_output_dbms_output/ut_output_dbms_output.get_lines.RetunrsNoRowsWhenNoDataInBuffer.sql @@lib/RunTest.sql ut_output_dbms_output/ut_output_dbms_output.get_lines.ReturnsSentLines.sql @@lib/RunTest.sql ut_output_dbms_output/ut_output_dbms_output.send_clob.SendsAClobIntoPipe.sql + --Global cleanup drop package ut_example_tests; drop procedure check_annotation_parsing; drop package ut_transaction_control; drop table ut$test_table; drop type department$; +drop package test_package_1; +drop package test_package_2; +drop package test_package_3; --Finally @@lib/RunSummary diff --git a/tests/helpers/test_package_1.pck b/tests/helpers/test_package_1.pck new file mode 100644 index 000000000..53021d39a --- /dev/null +++ b/tests/helpers/test_package_1.pck @@ -0,0 +1,69 @@ +create or replace package test_package_1 is + + --%suite + --%suitepackage(tests) + + gv_glob_val number; + + --%setup + procedure global_setup; + + --%teardown + procedure global_teardown; + + --%test + procedure test1; + + --%test + --%testsetup(test2_setup) + --%testteardown(test2_teardown) + procedure test2; + + procedure test2_setup; + + procedure test2_teardown; + +end test_package_1; +/ +create or replace package body test_package_1 is + + gv_var_1 number; + + gv_var_1_temp number; + + procedure global_setup is + begin + gv_var_1 := 1; + gv_glob_val := 1; + end; + + procedure global_teardown is + begin + gv_var_1 := 0; + gv_glob_val := 0; + end; + + procedure test1 is + begin + ut.expect(gv_var_1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(gv_var_1).to_equal(2); + end; + + procedure test2_setup is + begin + gv_var_1_temp := gv_var_1; + gv_var_1 := 2; + end; + + procedure test2_teardown is + begin + gv_var_1 := gv_var_1_temp; + gv_var_1_temp := null; + end; + +end test_package_1; +/ diff --git a/tests/helpers/test_package_2.pck b/tests/helpers/test_package_2.pck new file mode 100644 index 000000000..daa45364e --- /dev/null +++ b/tests/helpers/test_package_2.pck @@ -0,0 +1,69 @@ +create or replace package test_package_2 is + + --%suite + --%suitepackage(tests.test_package_1) + + gv_glob_val varchar2(1); + + --%setup + procedure global_setup; + + --%teardown + procedure global_teardown; + + --%test + procedure test1; + + --%test + --%testsetup(test2_setup) + --%testteardown(test2_teardown) + procedure test2; + + procedure test2_setup; + + procedure test2_teardown; + +end test_package_2; +/ +create or replace package body test_package_2 is + + gv_var_1 varchar2(1); + + gv_var_1_temp varchar2(1); + + procedure global_setup is + begin + gv_var_1 := 'a'; + gv_glob_val := 'z'; + end; + + procedure global_teardown is + begin + gv_var_1 := 'n'; + gv_glob_val := 'n'; + end; + + procedure test1 is + begin + ut.expect(gv_var_1).to_equal('a'); + end; + + procedure test2 is + begin + ut.expect(gv_var_1).to_equal('b'); + end; + + procedure test2_setup is + begin + gv_var_1_temp := gv_var_1; + gv_var_1 := 'b'; + end; + + procedure test2_teardown is + begin + gv_var_1 := gv_var_1_temp; + gv_var_1_temp := null; + end; + +end test_package_2; +/ diff --git a/tests/helpers/test_package_3.pck b/tests/helpers/test_package_3.pck new file mode 100644 index 000000000..d7ca7b0c5 --- /dev/null +++ b/tests/helpers/test_package_3.pck @@ -0,0 +1,69 @@ +create or replace package test_package_3 is + + --%suite + --%suitepackage(tests2) + + gv_glob_val number; + + --%setup + procedure global_setup; + + --%teardown + procedure global_teardown; + + --%test + procedure test1; + + --%test + --%testsetup(test2_setup) + --%testteardown(test2_teardown) + procedure test2; + + procedure test2_setup; + + procedure test2_teardown; + +end test_package_3; +/ +create or replace package body test_package_3 is + + gv_var_1 number; + + gv_var_1_temp number; + + procedure global_setup is + begin + gv_var_1 := 1; + gv_glob_val := 1; + end; + + procedure global_teardown is + begin + gv_var_1 := 0; + gv_glob_val := 0; + end; + + procedure test1 is + begin + ut.expect(gv_var_1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(gv_var_1).to_equal(2); + end; + + procedure test2_setup is + begin + gv_var_1_temp := gv_var_1; + gv_var_1 := 2; + end; + + procedure test2_teardown is + begin + gv_var_1 := gv_var_1_temp; + gv_var_1_temp := null; + end; + +end test_package_3; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql new file mode 100644 index 000000000..2d7f45304 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql @@ -0,0 +1,45 @@ +PROMPT Prepare runner for the schema + +--Arrange +declare + c_path varchar2(100) := USER; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; +begin + --Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path) + ,a_objects_to_run => l_objects_to_run); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(2); + + for i in 1 .. 2 loop + l_test0_suite := treat(l_objects_to_run(i) as ut_test_suite); + ut.expect(l_test0_suite.object_name in ('tests', 'tests2')).to_be_true; + + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + case l_test0_suite.object_name + when 'tests' then + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(3); + l_test2_suite := treat(l_test1_suite.items(3) as ut_test_suite); + + ut.expect(l_test2_suite.object_name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(2); + when 'tests2' then + ut.expect(l_test1_suite.object_name).to_equal('test_package_3'); + ut.expect(l_test1_suite.items.count).to_equal(2); + end case; + + end loop; + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql new file mode 100644 index 000000000..edc194a91 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByName.sql @@ -0,0 +1,36 @@ +PROMPT Prepare runner for the top 2 package by package name + +--Arrange +declare + c_path varchar2(100) := USER||'.test_package_2'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test2_suite := treat(l_test1_suite.items(1) as ut_test_suite); + + ut.expect(l_test2_suite.object_name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(2); + + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql new file mode 100644 index 000000000..2781e60b3 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageByPath.sql @@ -0,0 +1,36 @@ +PROMPT Prepare runner for the top 2 package by path + +--Arrange +declare + c_path varchar2(100) := USER||':tests.test_package_1.test_package_2'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test2_suite := treat(l_test1_suite.items(1) as ut_test_suite); + + ut.expect(l_test2_suite.object_name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(2); + + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql new file mode 100644 index 000000000..66d7bd70b --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTop2PackageProcedureByPath.sql @@ -0,0 +1,41 @@ +PROMPT Prepare runner for the top 2 package procedure by path + +--Arrange +declare + c_path varchar2(100) := USER||':tests.test_package_1.test_package_2.test2'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; + l_test_proc ut_test; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test2_suite := treat(l_test1_suite.items(1) as ut_test_suite); + + ut.expect(l_test2_suite.object_name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(1); + + l_test_proc := treat(l_test2_suite.items(1) as ut_test); + ut.expect(l_test_proc.object_name).to_equal('test2'); + ut.expect(l_test_proc.setup is not null).to_be_true; + ut.expect(l_test_proc.teardown is not null).to_be_true; + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql new file mode 100644 index 000000000..792de1160 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByName.sql @@ -0,0 +1,36 @@ +PROMPT Prepare runner for the top package by package name + +--Arrange +declare + c_path varchar2(100) := USER||'.test_package_1'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(3); + l_test2_suite := treat(l_test1_suite.items(3) as ut_test_suite); + + ut.expect(l_test2_suite.object_name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(2); + + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql new file mode 100644 index 000000000..be6747167 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql @@ -0,0 +1,36 @@ +PROMPT Prepare runner for the top package by path + +--Arrange +declare + c_path varchar2(100) := USER||':tests'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(3); + l_test2_suite := treat(l_test1_suite.items(3) as ut_test_suite); + + ut.expect(l_test2_suite.object_name).to_equal('test_package_2'); + ut.expect(l_test2_suite.items.count).to_equal(2); + + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql new file mode 100644 index 000000000..d4ec13720 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureByPath.sql @@ -0,0 +1,37 @@ +PROMPT Prepare runner for the top package procedure by path + +--Arrange +declare + c_path varchar2(100) := USER||':tests.test_package_1.test2'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test2_suite ut_test_suite; + l_test_proc ut_test; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_1'); + ut.expect(l_test1_suite.items.count).to_equal(1); + l_test_proc := treat(l_test1_suite.items(1) as ut_test); + + ut.expect(l_test_proc.object_name).to_equal('test2'); + ut.expect(l_test_proc.setup is not null).to_be_true; + ut.expect(l_test_proc.teardown is not null).to_be_true; + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql new file mode 100644 index 000000000..a8613bebd --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageProcedureWithoutSubsuitesByName.sql @@ -0,0 +1,36 @@ +PROMPT Prepare runner for the top package procedure without sub-suites by package name + +--Arrange +declare + c_path varchar2(100) := USER||'.test_package_2.test2'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; + l_test_proc ut_test; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_3'); + ut.expect(l_test1_suite.items.count).to_equal(1); + + l_test_proc := treat(l_test1_suite.items(1) as ut_test); + ut.expect(l_test_proc.object_name).to_equal('test2'); + ut.expect(l_test_proc.setup is not null).to_be_true; + ut.expect(l_test_proc.teardown is not null).to_be_true; + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql new file mode 100644 index 000000000..e7e3cbb06 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByName.sql @@ -0,0 +1,30 @@ +PROMPT Prepare runner for the top package without sub-suites by package name + +--Arrange +declare + c_path varchar2(100) := USER||'.test_package_3'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests2'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_3'); + ut.expect(l_test1_suite.items.count).to_equal(2); + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/ diff --git a/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql new file mode 100644 index 000000000..032411693 --- /dev/null +++ b/tests/ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageWithoutSubsuitesByPath.sql @@ -0,0 +1,30 @@ +PROMPT Prepare runner for the top package without subsuites by path + +--Arrange +declare + c_path varchar2(100) := USER||':tests2.test_package_3'; + l_objects_to_run ut_objects_list; + + l_test0_suite ut_test_suite; + l_test1_suite ut_test_suite; +begin +--Act + ut_suite_manager.configure_execution_by_path(a_paths => ut_varchar2_list(c_path), a_objects_to_run => l_objects_to_run); + +--Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut_test_suite); + + ut.expect(l_test0_suite.object_name).to_equal('tests2'); + ut.expect(l_test0_suite.items.count).to_equal(1); + l_test1_suite := treat(l_test0_suite.items(1) as ut_test_suite); + + ut.expect(l_test1_suite.object_name).to_equal('test_package_3'); + ut.expect(l_test1_suite.items.count).to_equal(2); + + if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then + :test_result := ut_utils.tr_success; + end if; + +end; +/