From 987d3911c703ce9da8334b6a4cc3a8c9d0d4c49f Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Sun, 6 Feb 2022 15:49:24 +0000 Subject: [PATCH 1/7] Update code. --- docs/userguide/annotations.md | 58 +- source/api/ut_suite_item_info.tpb | 6 +- source/api/ut_suite_item_info.tps | 3 +- source/core/types/ut_logical_suite.tpb | 4 +- source/core/types/ut_logical_suite.tps | 4 +- source/core/types/ut_run.tpb | 2 +- source/core/types/ut_run.tps | 2 +- source/core/types/ut_suite.tpb | 2 +- source/core/types/ut_suite_cache_row.tps | 3 +- source/core/types/ut_suite_item.tpb | 1 + source/core/types/ut_suite_item.tps | 6 +- source/core/types/ut_test.tpb | 5 +- source/core/types/ut_test.tps | 2 +- source/core/ut_suite_builder.pkb | 14 +- source/core/ut_suite_cache_manager.pkb | 12 +- source/core/ut_suite_manager.pkb | 14 +- .../reporters/ut_documentation_reporter.tpb | 6 +- test/install_ut3_tester_tests.sql | 2 + .../test_annot_disabled_reason.pkb | 533 ++++++++++++++++++ .../test_annot_disabled_reason.pks | 31 + test/ut3_user/api/test_ut_runner.pkb | 20 +- 21 files changed, 685 insertions(+), 45 deletions(-) create mode 100644 test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb create mode 100644 test/ut3_tester/core/annotations/test_annot_disabled_reason.pks diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 1b9b4faee..92cae5d71 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -140,7 +140,7 @@ end; | `--%beforetest([[.].][,...])` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | | `--%aftertest([[.].][,...])` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | | `--%rollback()` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | -| `--%disabled` | Package/procedure | Used to disable a suite or a test. Disabled suites/tests do not get executed, they are however marked and reported as disabled in a test run. | +| `--%disabled()` | Package/procedure | Used to disable a suite, whole context or a test. Disabled suites/contexts/tests do not get executed, they are however marked and reported as disabled in a test run. The reason that will be displayed next to disabled tests is decided based on hierarchy suites -> context -> test | | `--%context()` | Package | Denotes start of a named context (sub-suite) in a suite package an optional description for context can be provided. | | `--%name()` | Package | Denotes name for a context. Must be placed after the context annotation and before start of nested context. | | `--%endcontext` | Package | Denotes end of a nested context (sub-suite) in a suite package | @@ -343,12 +343,13 @@ Finished in .008815 seconds ### Disabled Marks annotated suite package or test procedure as disabled. +You can provide the reason why the test is disabled that will be displayed in output. Disabling suite. ```sql create or replace package test_package as --%suite(Tests for a package) - --%disabled + --%disabled(Reason for disabling suite) --%test(Description of tested behavior) procedure some_test; @@ -371,13 +372,58 @@ exec ut.run('test_package'); ``` ``` Tests for a package - Description of tested behavior [0 sec] (DISABLED) - Description of another behavior [0 sec] (DISABLED) + Description of tested behavior [0 sec] (DISABLED - Reason for disabling suite) + Description of another behavior [0 sec] (DISABLED - Reason for disabling suite) Finished in .001441 seconds 2 tests, 0 failed, 0 errored, 2 disabled, 0 warning(s) ``` +Disabling the context(s). +```sql +create or replace package test_package as + --%suite(Tests for a package) + + --%context(Context1) + + --%test(Description of tested behavior) + procedure some_test; + + --%endcontext + + --%context(Context2) + + --%disabled(Reason for disabling context2) + + --%test(Description of another behavior) + procedure other_test; + + --%endcontext +end; +/ +create or replace package body test_package as + + procedure some_test is begin null; end; + + procedure other_test is begin null; end; +end; +/ +``` + +```sql +exec ut.run('test_package'); +``` +``` +Tests for a package + Context1 + Description of tested behavior [.002 sec] + Context2 + Description of another behavior [0 sec] (DISABLED - Reason for disabling context2) + +Finished in .005079 seconds +2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) +``` + Disabling individual test(s). ```sql create or replace package test_package as @@ -387,7 +433,7 @@ create or replace package test_package as procedure some_test; --%test(Description of another behavior) - --%disabled + --%disabled(Reason for disabling test) procedure other_test; end; / @@ -406,7 +452,7 @@ exec ut.run('test_package'); ``` Tests for a package Description of tested behavior [.004 sec] - Description of another behavior [0 sec] (DISABLED) + Description of another behavior [0 sec] (DISABLED - Reason for disabling test) Finished in .005868 seconds 2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) diff --git a/source/api/ut_suite_item_info.tpb b/source/api/ut_suite_item_info.tpb index 97d931c59..3315f7a16 100644 --- a/source/api/ut_suite_item_info.tpb +++ b/source/api/ut_suite_item_info.tpb @@ -17,7 +17,7 @@ create or replace type body ut_suite_item_info is */ constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2, a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer, - a_tags ut_varchar2_rows) return self as result is + a_disabled_reason varchar2, a_tags ut_varchar2_rows) return self as result is begin self.object_owner := a_object_owner; self.object_name := a_object_name; @@ -27,6 +27,10 @@ create or replace type body ut_suite_item_info is self.item_line_no := a_item_line_no; self.path := a_path; self.disabled_flag := a_disabled_flag; + self.disabled_reason := case when + a_disabled_flag = 1 then a_disabled_reason + else null + end; self.tags := case when a_tags is null then null when a_tags.count = 0 then null diff --git a/source/api/ut_suite_item_info.tps b/source/api/ut_suite_item_info.tps index 2c0f16198..2c92f261d 100644 --- a/source/api/ut_suite_item_info.tps +++ b/source/api/ut_suite_item_info.tps @@ -23,9 +23,10 @@ create or replace type ut_suite_item_info as object ( item_line_no integer, -- line_number where annotation identifying the item exists path varchar2( 4000 ),-- suitepath of the item disabled_flag integer, -- 0 (zero) if item is not disabled, 1 if item is disabled by --%disabled annotation + disabled_reason varchar2(4000), -- if disable flag is set then you can pass reason tags varchar2(4000), constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2, a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer, - a_tags ut_varchar2_rows) return self as result + a_disabled_reason varchar2, a_tags ut_varchar2_rows) return self as result ) / diff --git a/source/core/types/ut_logical_suite.tpb b/source/core/types/ut_logical_suite.tpb index 486cb83e7..036d40d51 100644 --- a/source/core/types/ut_logical_suite.tpb +++ b/source/core/types/ut_logical_suite.tpb @@ -16,12 +16,12 @@ create or replace type body ut_logical_suite as limitations under the License. */ - overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite) is + overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2) is begin ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); self.start_time := current_timestamp; for i in 1 .. self.items.count loop - self.items(i).mark_as_skipped(); + self.items(i).mark_as_skipped(coalesce(a_skip_reason,self.disabled_reason)); end loop; self.end_time := self.start_time; ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self); diff --git a/source/core/types/ut_logical_suite.tps b/source/core/types/ut_logical_suite.tps index 0f816f26b..c4f2f699b 100644 --- a/source/core/types/ut_logical_suite.tps +++ b/source/core/types/ut_logical_suite.tps @@ -1,4 +1,4 @@ -create or replace type ut_logical_suite under ut_suite_item ( +create or replace type ut_logical_suite force under ut_suite_item ( /* utPLSQL - Version 3 Copyright 2016 - 2021 utPLSQL Project @@ -21,7 +21,7 @@ create or replace type ut_logical_suite under ut_suite_item ( */ items ut_suite_items, - overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite), + overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2), overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false), overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean, overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite), diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index 258396427..cdafb30fc 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -39,7 +39,7 @@ create or replace type body ut_run as return; end; - overriding member procedure mark_as_skipped(self in out nocopy ut_run) is + overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2) is begin null; end; diff --git a/source/core/types/ut_run.tps b/source/core/types/ut_run.tps index f556934ce..debf847cd 100644 --- a/source/core/types/ut_run.tps +++ b/source/core/types/ut_run.tps @@ -36,7 +36,7 @@ create or replace type ut_run under ut_suite_item ( a_random_test_order_seed positive := null, a_run_tags ut_varchar2_rows := null ) return self as result, - overriding member procedure mark_as_skipped(self in out nocopy ut_run), + overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2), overriding member function do_execute(self in out nocopy ut_run) return boolean, overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false), overriding member procedure calc_execution_result(self in out nocopy ut_run), diff --git a/source/core/types/ut_suite.tpb b/source/core/types/ut_suite.tpb index 2ec1c9ccd..e3a4687d8 100644 --- a/source/core/types/ut_suite.tpb +++ b/source/core/types/ut_suite.tpb @@ -44,7 +44,7 @@ create or replace type body ut_suite as ut_utils.debug_log('ut_suite.execute'); if self.get_disabled_flag() then - self.mark_as_skipped(); + self.mark_as_skipped(a_skip_reason => self.disabled_reason); else self.start_time := current_timestamp; ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); diff --git a/source/core/types/ut_suite_cache_row.tps b/source/core/types/ut_suite_cache_row.tps index 9c5990bfd..c147a8757 100644 --- a/source/core/types/ut_suite_cache_row.tps +++ b/source/core/types/ut_suite_cache_row.tps @@ -1,4 +1,4 @@ -create type ut_suite_cache_row as object ( +create or replace type ut_suite_cache_row as object ( /* utPLSQL - Version 3 Copyright 2016 - 2021 utPLSQL Project @@ -26,6 +26,7 @@ create type ut_suite_cache_row as object ( description varchar2(4000 byte), rollback_type number, disabled_flag number, + disabled_reason varchar2(4000 byte), warnings ut_varchar2_rows, before_all_list ut_executables, after_all_list ut_executables, diff --git a/source/core/types/ut_suite_item.tpb b/source/core/types/ut_suite_item.tpb index 12f857cba..648f10dd1 100644 --- a/source/core/types/ut_suite_item.tpb +++ b/source/core/types/ut_suite_item.tpb @@ -26,6 +26,7 @@ create or replace type body ut_suite_item as self.line_no := a_line_no; self.transaction_invalidators := ut_varchar2_list(); self.disabled_flag := ut_utils.boolean_to_int(false); + self.disabled_reason := null; end; member function get_disabled_flag return boolean is diff --git a/source/core/types/ut_suite_item.tps b/source/core/types/ut_suite_item.tps index d96ec8c30..8184f2a63 100644 --- a/source/core/types/ut_suite_item.tps +++ b/source/core/types/ut_suite_item.tps @@ -46,6 +46,10 @@ create or replace type ut_suite_item force under ut_event_item ( */ disabled_flag integer(1), /** + * Indicates reason whysa test is to be disabled by execution + */ + disabled_reason varchar2(4000), + /** * Line no where annotation identifying this item is placed in package */ line_no integer, @@ -66,7 +70,7 @@ create or replace type ut_suite_item force under ut_event_item ( tags ut_varchar2_rows, member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer), member function get_disabled_flag return boolean, - not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item), + not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item, a_skip_reason in varchar2), member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer, a_force boolean := false), member function get_rollback_type return integer, member function create_savepoint_if_needed return varchar2, diff --git a/source/core/types/ut_test.tpb b/source/core/types/ut_test.tpb index 9a36205c1..946f8990d 100644 --- a/source/core/types/ut_test.tpb +++ b/source/core/types/ut_test.tpb @@ -35,11 +35,12 @@ create or replace type body ut_test as return; end; - overriding member procedure mark_as_skipped(self in out nocopy ut_test) is + overriding member procedure mark_as_skipped(self in out nocopy ut_test, a_skip_reason in varchar2) is begin ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); self.start_time := current_timestamp; self.result := ut_utils.gc_disabled; + self.disabled_reason := coalesce(a_skip_reason,self.disabled_reason); ut_utils.debug_log('ut_test.execute - disabled'); self.results_count.set_counter_values(self.result); self.end_time := self.start_time; @@ -54,7 +55,7 @@ create or replace type body ut_test as ut_utils.debug_log('ut_test.execute'); if self.get_disabled_flag() then - mark_as_skipped(); + mark_as_skipped(self.disabled_reason); else self.start_time := current_timestamp; ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); diff --git a/source/core/types/ut_test.tps b/source/core/types/ut_test.tps index 07958ec0f..dbba64961 100644 --- a/source/core/types/ut_test.tps +++ b/source/core/types/ut_test.tps @@ -59,7 +59,7 @@ create or replace type ut_test force under ut_suite_item ( self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, a_line_no integer, a_expected_error_codes ut_varchar2_rows := null, a_tags ut_varchar2_rows := null ) return self as result, - overriding member procedure mark_as_skipped(self in out nocopy ut_test), + overriding member procedure mark_as_skipped(self in out nocopy ut_test, a_skip_reason in varchar2), overriding member function do_execute(self in out nocopy ut_test) return boolean, overriding member procedure calc_execution_result(self in out nocopy ut_test), overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2), diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 2dac6b4ad..7ad24bd57 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -355,6 +355,7 @@ create or replace package body ut_suite_builder is l_annotation_texts tt_annotation_texts; l_proc_annotations tt_annotations_by_name := a_annotations.by_proc(a_procedure_name); begin + if not l_proc_annotations.exists(gc_test) then return; end if; @@ -412,6 +413,12 @@ create or replace package body ut_suite_builder is end if; l_test.disabled_flag := ut_utils.boolean_to_int( l_proc_annotations.exists( gc_disabled)); + if l_proc_annotations.exists(gc_disabled) then + l_annotation_texts := l_proc_annotations( gc_disabled); + --take the last definition if more than one was provided + l_test.disabled_reason := l_annotation_texts(l_annotation_texts.first); + end if; + a_suite_items.extend; a_suite_items( a_suite_items.last ) := l_test; @@ -560,8 +567,13 @@ create or replace package body ut_suite_builder is if a_annotations.by_name.exists(gc_tags) then add_tags_to_suite_item(a_suite, a_annotations.by_name(gc_tags),a_suite.tags); end if; + a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled)); - + if a_annotations.by_name.exists(gc_disabled) then + l_annotation_text := trim(a_annotations.by_name(gc_disabled)(a_annotations.by_name(gc_disabled).first)); + a_suite.disabled_reason := l_annotation_text; + end if; + --process procedure annotations for suite get_annotated_procedures(a_annotations, a_suite, a_suite_items, l_before_each_list, l_after_each_list, l_before_all_list, l_after_all_list); diff --git a/source/core/ut_suite_cache_manager.pkb b/source/core/ut_suite_cache_manager.pkb index 0ae8d7104..ad1634c10 100644 --- a/source/core/ut_suite_cache_manager.pkb +++ b/source/core/ut_suite_cache_manager.pkb @@ -67,7 +67,7 @@ create or replace package body ut_suite_cache_manager is select ut_suite_cache_row( null, s.self_type, s.path, s.object_owner, s.object_name, - s.object_name, null, null, null, null, 0, + s.object_name, null, null, null, null, 0,null, ut_varchar2_rows(), s.x, s.x, s.x, s.x, s.x, s.x, s.y, null, s.z @@ -325,7 +325,7 @@ create or replace package body ut_suite_cache_manager is ( id, self_type, path, object_owner, object_name, name, line_no, parse_time, description, - rollback_type, disabled_flag, warnings, + rollback_type, disabled_flag,disabled_reason, warnings, before_all_list, after_all_list, before_each_list, after_each_list, before_test_list, after_test_list, @@ -339,7 +339,7 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path, upper(s.i.object_owner) as object_owner, upper(s.i.object_name) as object_name, upper(s.i.name) as name, s.i.line_no as line_no, s.i.parse_time as parse_time, s.i.description as description, - s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag, s.i.warnings as warnings, + s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag,s.i.disabled_reason as disabled_reason, s.i.warnings as warnings, s.i.before_all_list as before_all_list, s.i.after_all_list as after_all_list, null before_each_list, null after_each_list, null before_test_list, null after_test_list, @@ -351,7 +351,7 @@ create or replace package body ut_suite_cache_manager is ( id, self_type, path, object_owner, object_name, name, line_no, parse_time, description, - rollback_type, disabled_flag, warnings, + rollback_type, disabled_flag,disabled_reason, warnings, before_all_list, after_all_list, before_each_list, after_each_list, before_test_list, after_test_list, @@ -365,7 +365,7 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path, upper(s.t.object_owner) as object_owner, upper(s.t.object_name) as object_name, upper(s.t.name) as name, s.t.line_no as line_no, s.t.parse_time as parse_time, s.t.description as description, - s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.warnings as warnings, + s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.disabled_reason as disabled_reason, s.t.warnings as warnings, null before_all_list, null after_all_list, s.t.before_each_list as before_each_list, s.t.after_each_list as after_each_list, s.t.before_test_list as before_test_list, s.t.after_test_list as after_test_list, @@ -408,7 +408,7 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ ut_suite_item_info( c.object_owner, c.object_name, c.name, c.description, c.self_type, c.line_no, - c.path, c.disabled_flag, c.tags + c.path, c.disabled_flag, c.disabled_reason, c.tags ) bulk collect into l_results from table(l_cache_rows) c; diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 8a5bcb9b8..4bcb83afa 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -187,7 +187,7 @@ create or replace package body ut_suite_manager is self_type => a_rows( a_idx ).self_type, object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -200,7 +200,7 @@ create or replace package body ut_suite_manager is self_type => a_rows( a_idx ).self_type, object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -216,7 +216,7 @@ create or replace package body ut_suite_manager is self_type => a_rows( a_idx ).self_type, object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -229,7 +229,7 @@ create or replace package body ut_suite_manager is self_type => a_rows( a_idx ).self_type, object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -245,7 +245,7 @@ create or replace package body ut_suite_manager is self_type => a_rows( a_idx ).self_type, object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -256,7 +256,7 @@ create or replace package body ut_suite_manager is self_type => a_rows( a_idx ).self_type, object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), @@ -269,7 +269,7 @@ create or replace package body ut_suite_manager is self_type => a_rows(a_idx).self_type, object_owner => a_rows(a_idx).object_owner, object_name => lower(a_rows(a_idx).object_name), name => lower(a_rows(a_idx).name), description => a_rows(a_idx).description, path => a_rows(a_idx).path, - rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag, + rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, line_no => a_rows(a_idx).line_no, parse_time => a_rows(a_idx).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows(a_idx).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), diff --git a/source/reporters/ut_documentation_reporter.tpb b/source/reporters/ut_documentation_reporter.tpb index 8b92d447f..1dbe0cb92 100644 --- a/source/reporters/ut_documentation_reporter.tpb +++ b/source/reporters/ut_documentation_reporter.tpb @@ -68,7 +68,11 @@ create or replace type body ut_documentation_reporter is l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]'; --if test failed, then add it to the failures list, print failure with number if a_test.result = ut_utils.gc_disabled then - self.print_yellow_text(l_message || ' (DISABLED)'); + self.print_yellow_text(l_message || ' (DISABLED'|| + case when a_test.disabled_reason is not null + then ' - '||a_test.disabled_reason + else null + end || ')'); elsif a_test.result = ut_utils.gc_success then self.print_green_text(l_message); elsif a_test.result > ut_utils.gc_success then diff --git a/test/install_ut3_tester_tests.sql b/test/install_ut3_tester_tests.sql index 9548d5148..8163a39f2 100644 --- a/test/install_ut3_tester_tests.sql +++ b/test/install_ut3_tester_tests.sql @@ -14,6 +14,7 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/annotations/test_annot_throws_exception.pks @@ut3_tester/core/annotations/test_annotation_manager.pks @@ut3_tester/core/annotations/test_annotation_cache.pks +@@ut3_tester/core/annotations/test_annot_disabled_reason.pks @@ut3_tester/core/expectations/test_expectation_processor.pks @@ut3_tester/core/test_ut_utils.pks @@ut3_tester/core/test_ut_test.pks @@ -31,6 +32,7 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/annotations/test_annotation_manager.pkb @@ut3_tester/core/annotations/test_annot_throws_exception.pkb @@ut3_tester/core/annotations/test_annotation_cache.pkb +@@ut3_tester/core/annotations/test_annot_disabled_reason.pkb @@ut3_tester/core/expectations/test_expectation_processor.pkb @@ut3_tester/core/test_ut_utils.pkb @@ut3_tester/core/test_ut_test.pkb diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb new file mode 100644 index 000000000..70015484f --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb @@ -0,0 +1,533 @@ +create or replace package body test_annot_disabled_reason +is + + procedure compile_dummy_packages is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_package_1 is + + --%suite + --%displayname(disable_test_suite_level) + --%suitepath(tests) + --%rollback(manual) + + --%disabled( Tests are disabled on suite level ) + + --%context( First context ) + + --%test(Test1 from test package 1) + procedure test1; + + --%test(Test2 from test package 1) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%test(Test3 from test package 1) + procedure test3; + + --%test(Test4 from test package 1) + procedure test4; + + --%endcontext + +end test_package_1;]'; + + execute immediate q'[create or replace package body test_package_1 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_1;]'; + + execute immediate q'[create or replace package test_package_2 is + + --%suite + --%displayname(Disable on context level) + --%suitepath(tests) + --%rollback(manual) + + --%context( First context ) + + --%disabled( Tests and disabled on first context level ) + + --%test(Test1 from test package 2) + procedure test1; + + --%test(Test2 from test package 2) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%test(Test3 from test package 2) + procedure test3; + + --%test(Test4 from test package 3) + procedure test4; + + --%endcontext + +end test_package_2;]'; + + execute immediate q'[create or replace package body test_package_2 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_2;]'; + + execute immediate q'[create or replace package test_package_3 is + + --%suite + --%displayname(Disable tests on test level) + --%suitepath(tests) + --%rollback(manual) + + --%context( First context ) + + --%test(Test1 from test package 3) + --%disabled( Test1 disabled from first context ) + procedure test1; + + --%test(Test2 from test package 3) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%test(Test3 from test package 3) + procedure test3; + + --%test(Test4 from test package 3) + --%disabled( Test4 disabled from second context ) + procedure test4; + + --%endcontext + +end test_package_3;]'; + + execute immediate q'[create or replace package body test_package_3 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_3;]'; + + execute immediate q'[create or replace package test_package_4 is + + --%suite + --%displayname(Disable reason is very long or have special characters) + --%suitepath(tests) + --%rollback(manual) + + + --%test(Test1 from test package 4) + --%disabled( $#?!%*&-/\^ ) + procedure test1; + + --%test(Test2 from test package 4) --%disabled(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) + procedure test2; + +end test_package_4;]'; + + execute immediate q'[create or replace package body test_package_4 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_4;]'; + + execute immediate q'[create or replace package test_package_5 is + + --%suite + --%displayname(Disable tests on suite level overriding rest) + --%suitepath(tests) + --%rollback(manual) + + --%disabled( Disable on suite level ) + + --%context( First context ) + + --%disabled( Disable on 1st context level ) + + --%test(Test1 from test package 3) + --%disabled( Disable on 1st test level ) + procedure test1; + + --%test(Test2 from test package 3) + --%disabled( Disable on 2nd test level ) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%disabled( Disable on 2nd context level ) + + --%test(Test3 from test package 3) + --%disabled( Disable on 3rd test level ) + procedure test3; + + --%test(Test4 from test package 3) + --%disabled( Disable on 4th test level ) + procedure test4; + + --%endcontext + +end test_package_5;]'; + + execute immediate q'[create or replace package body test_package_5 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_5;]'; + + execute immediate q'[create or replace package test_package_6 is + + --%suite + --%displayname(Disable tests on each of ctx level overriding rest) + --%suitepath(tests) + --%rollback(manual) + + --%context( First context ) + + --%disabled( Disable on 1st context level ) + + --%test(Test1 from test package 3) + --%disabled( Disable on 1st test level ) + procedure test1; + + --%test(Test2 from test package 3) + --%disabled( Disable on 2nd test level ) + procedure test2; + + --%endcontext + + --%context( Second context ) + + --%disabled( Disable on 2nd context level ) + + --%test(Test3 from test package 3) + --%disabled( Disable on 3rd test level ) + procedure test3; + + --%test(Test4 from test package 3) + --%disabled( Disable on 4th test level ) + procedure test4; + + --%endcontext + +end test_package_6;]'; + + execute immediate q'[create or replace package body test_package_6 is + + procedure test1 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test2 is + begin + ut.expect(2).to_equal(2); + end; + + procedure test3 is + begin + ut.expect(1).to_equal(1); + end; + + procedure test4 is + begin + ut.expect(2).to_equal(2); + end; + +end test_package_6;]'; + + end; + + + procedure drop_dummy_packages is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_package_1'; + execute immediate 'drop package test_package_2'; + execute immediate 'drop package test_package_3'; + execute immediate 'drop package test_package_4'; + execute immediate 'drop package test_package_5'; + execute immediate 'drop package test_package_6'; + end; + + procedure test_disable_on_suite_level is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'; + l_objects_to_run ut3_develop.ut_suite_items; + + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); + + ut.expect(l_test1_suite.items(1).name).to_equal('test1'); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); + + ut.expect(l_test1_suite.items(2).name).to_equal('test2'); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); + + ut.expect(l_test1_suite.items(3).name).to_equal('test3'); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); + + ut.expect(l_test1_suite.items(4).name).to_equal('test4'); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); + + end; + + procedure test_dis_on_1st_ctx_level is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'; + l_objects_to_run ut3_develop.ut_suite_items; + + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); + + ut.expect(l_test1_suite.items(1).name).to_equal('test1'); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Tests and disabled on first context level'); + + ut.expect(l_test1_suite.items(2).name).to_equal('test2'); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Tests and disabled on first context level'); + + ut.expect(l_test1_suite.items(3).name).to_equal('test3'); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_be_null; + + ut.expect(l_test1_suite.items(4).name).to_equal('test4'); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_be_null; + + end; + + procedure test_disable_tests_level is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_3'; + l_objects_to_run ut3_develop.ut_suite_items; + + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); + + ut.expect(l_test1_suite.items(1).name).to_equal('test1'); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Test1 disabled from first context'); + + ut.expect(l_test1_suite.items(2).name).to_equal('test2'); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_be_null; + + ut.expect(l_test1_suite.items(3).name).to_equal('test3'); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(0); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_be_null; + + ut.expect(l_test1_suite.items(4).name).to_equal('test4'); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Test4 disabled from second context'); + + end; + + procedure test_long_text_spec_chr is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_4'; + l_objects_to_run ut3_develop.ut_suite_items; + + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); + + ut.expect(l_test1_suite.items(1).name).to_equal('test1'); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('$#?!%*&-/\^'); + + ut.expect(l_test1_suite.items(2).name).to_equal('test2'); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext'); + + + end; + + procedure test_disable_suite_ctx_tst is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_5'; + l_objects_to_run ut3_develop.ut_suite_items; + + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); + + ut.expect(l_test1_suite.items(1).name).to_equal('test1'); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); + + ut.expect(l_test1_suite.items(2).name).to_equal('test2'); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); + + ut.expect(l_test1_suite.items(3).name).to_equal('test3'); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); + + ut.expect(l_test1_suite.items(4).name).to_equal('test4'); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); + + end; + + procedure test_disable_ctx_tst is + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_6'; + l_objects_to_run ut3_develop.ut_suite_items; + + l_test0_suite ut3_develop.ut_logical_suite; + l_test1_suite ut3_develop.ut_suite; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); + + --Assert + ut.expect(l_objects_to_run.count).to_equal(1); + l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); + l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); + + ut.expect(l_test1_suite.items(1).name).to_equal('test1'); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 1st context level'); + + ut.expect(l_test1_suite.items(2).name).to_equal('test2'); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 1st context level'); + + ut.expect(l_test1_suite.items(3).name).to_equal('test3'); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 2nd context level'); + + ut.expect(l_test1_suite.items(4).name).to_equal('test4'); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); + ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 2nd context level'); + + end; + +end; +/ diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks new file mode 100644 index 000000000..cae5da1ee --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks @@ -0,0 +1,31 @@ +create or replace package test_annot_disabled_reason +is + --%suite(annotations - disabled) + --%suitepath(utplsql.ut3_tester.core.annotations) + + --%beforeall + procedure compile_dummy_packages; + + --%afterall + procedure drop_dummy_packages; + + --%test(Disable all tests under the suite displaying suite level reason) + procedure test_disable_on_suite_level; + + --%test(Disable all tests under one of two contexts displaying context level reason) + procedure test_dis_on_1st_ctx_level; + + --%test(Disable a single tests from each of the contexts displaying test level reason) + procedure test_disable_tests_level; + + --%test(Disable tests with reason using special characters and long reason) + procedure test_long_text_spec_chr; + + --%test(Disable tests on suite , context and test level and display suite level reason) + procedure test_disable_suite_ctx_tst; + + --%test(Disable tests on context and test level and display context level reason) + procedure test_disable_ctx_tst; + +end; +/ diff --git a/test/ut3_user/api/test_ut_runner.pkb b/test/ut3_user/api/test_ut_runner.pkb index 2aa624ed8..a24fc2d51 100644 --- a/test/ut3_user/api/test_ut_runner.pkb +++ b/test/ut3_user/api/test_ut_runner.pkb @@ -267,22 +267,22 @@ end;'; select 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'some.path.dummy_test_package' path, 0 disabled_flag,null tags + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,null tags from dual union all select 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,null tags + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,null tags from dual union all select 'UT3$USER#' object_owner, 'PATH' object_name, 'PATH' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null tags + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags from dual union all select 'UT3$USER#' object_owner, 'SOME' object_name, 'SOME' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null tags + 'some' path, 0 disabled_flag, null disabled_reason, null tags from dual; --Act open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); @@ -299,22 +299,22 @@ end;'; select 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'some.path.dummy_test_package' path, 0 disabled_flag,'dummy' tags + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,'dummy' tags from dual union all select 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 7 item_line_no, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,'testtag' tags + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,'testtag' tags from dual union all select 'UT3$USER#' object_owner, 'PATH' object_name, 'PATH' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null tags + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags from dual union all select 'UT3$USER#' object_owner, 'SOME' object_name, 'SOME' item_name, null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null tags + 'some' path, 0 disabled_flag, null disabled_reason, null tags from dual; --Act open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); @@ -331,12 +331,12 @@ end;'; select 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'dummy_test_package' path, 0 disabled_flag,'suitetag1,suitetag2' tags + 'dummy_test_package' path, 0 disabled_flag, null disabled_reason,'suitetag1,suitetag2' tags from dual union all select 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, - 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,'testtag1,testtag2' tags + 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,'testtag1,testtag2' tags from dual; --Act open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); From fddde601f3895f2e7ab24866dd5b9dc4213647ee Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Sun, 6 Feb 2022 17:09:07 +0000 Subject: [PATCH 2/7] Updating testss --- .../test_annot_disabled_reason.pkb | 261 +++++++----------- 1 file changed, 106 insertions(+), 155 deletions(-) diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb index 70015484f..e3df44425 100644 --- a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb +++ b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb @@ -1,6 +1,7 @@ create or replace package body test_annot_disabled_reason is + procedure compile_dummy_packages is pragma autonomous_transaction; begin @@ -181,7 +182,8 @@ end test_package_3;]'; --%disabled( $#?!%*&-/\^ ) procedure test1; - --%test(Test2 from test package 4) --%disabled(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) + --%test(Test2 from test package 4) + --%disabled(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) procedure test2; end test_package_4;]'; @@ -339,193 +341,142 @@ end test_package_6;]'; end; procedure test_disable_on_suite_level is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); - - ut.expect(l_test1_suite.items(3).name).to_equal('test3'); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); - - ut.expect(l_test1_suite.items(4).name).to_equal('test4'); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Tests are disabled on suite level'); + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%disable_test_suite_level +%First context +%Test1 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) +%Test2 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) +%Second context +%Test3 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) +%Test4 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level)%]'; + ut.expect(l_actual_message).to_be_like(l_expected_message); end; procedure test_dis_on_1st_ctx_level is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Tests and disabled on first context level'); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Tests and disabled on first context level'); - - ut.expect(l_test1_suite.items(3).name).to_equal('test3'); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(0); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_be_null; - - ut.expect(l_test1_suite.items(4).name).to_equal('test4'); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(0); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_be_null; + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable on context level +%First context +%Test1 from test package 2 [0 sec] (DISABLED - Tests and disabled on first context level) +%Test2 from test package 2 [0 sec] (DISABLED - Tests and disabled on first context level) +%Second context +%Test3 from test package 2 [% sec] +%Test4 from test package 3 [% sec]%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); end; procedure test_disable_tests_level is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_3'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Test1 disabled from first context'); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_be_null; - - ut.expect(l_test1_suite.items(3).name).to_equal('test3'); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(0); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_be_null; - - ut.expect(l_test1_suite.items(4).name).to_equal('test4'); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Test4 disabled from second context'); + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_3'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable tests on test level +%First context +%Test1 from test package 3 [0 sec] (DISABLED - Test1 disabled from first context) +%Test2 from test package 3 [% sec] +%Second context +%Test3 from test package 3 [% sec] +%Test4 from test package 3 [0 sec] (DISABLED - Test4 disabled from second context)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; procedure test_long_text_spec_chr is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_4'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('$#?!%*&-/\^'); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext'); + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_4'))); + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable reason is very long or have special characters +%Test1 from test package 4 [0 sec] (DISABLED - $#?!%*&-/\^) +%Test2 from test package 4 [0 sec] (DISABLED - verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext)%]'; + ut.expect(l_actual_message).to_be_like(l_expected_message); end; procedure test_disable_suite_ctx_tst is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_5'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); - - ut.expect(l_test1_suite.items(3).name).to_equal('test3'); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); - - ut.expect(l_test1_suite.items(4).name).to_equal('test4'); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on suite level'); + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_5'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable tests on suite level overriding rest +%First context +%Test1 from test package 3 [0 sec] (DISABLED - Disable on suite level) +%Test2 from test package 3 [0 sec] (DISABLED - Disable on suite level) +%Second context +%Test3 from test package 3 [0 sec] (DISABLED - Disable on suite level) +%Test4 from test package 3 [0 sec] (DISABLED - Disable on suite level)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; procedure test_disable_ctx_tst is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_6'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; + l_test_results ut3_develop.ut_varchar2_list; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); begin --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 1st context level'); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 1st context level'); - - ut.expect(l_test1_suite.items(3).name).to_equal('test3'); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(3) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 2nd context level'); - - ut.expect(l_test1_suite.items(4).name).to_equal('test4'); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_flag).to_equal(1); - ut.expect(treat(l_test1_suite.items(4) as ut3_develop.ut_test).disabled_reason).to_equal('Disable on 2nd context level'); + + select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_6'))); + + l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); + + l_expected_message := q'[%tests +%Disable tests on each of ctx level overriding rest +%First context +%Test1 from test package 3 [0 sec] (DISABLED - Disable on 1st context level) +%Test2 from test package 3 [0 sec] (DISABLED - Disable on 1st context level) +%Second context +%Test3 from test package 3 [0 sec] (DISABLED - Disable on 2nd context level) +%Test4 from test package 3 [0 sec] (DISABLED - Disable on 2nd context level)%]'; + + ut.expect(l_actual_message).to_be_like(l_expected_message); end; From 79da316a860c4eb2dd7aa11253b377aa3e4a3772 Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Mon, 7 Feb 2022 09:06:00 +0000 Subject: [PATCH 3/7] Resolving a code comments --- source/core/ut_suite_builder.pkb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 7ad24bd57..ebb113370 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -570,8 +570,7 @@ create or replace package body ut_suite_builder is a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled)); if a_annotations.by_name.exists(gc_disabled) then - l_annotation_text := trim(a_annotations.by_name(gc_disabled)(a_annotations.by_name(gc_disabled).first)); - a_suite.disabled_reason := l_annotation_text; + a_suite.disabled_reason := a_annotations.by_name(gc_disabled)(a_annotations.by_name(gc_disabled).first); end if; --process procedure annotations for suite From ed156d791f979196b3a0dd4b986f2e527733059f Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Mon, 7 Feb 2022 13:32:50 +0000 Subject: [PATCH 4/7] Updating reporters --- source/reporters/ut_junit_reporter.tpb | 8 +++++++- source/reporters/ut_teamcity_reporter.tpb | 2 +- source/reporters/ut_teamcity_reporter_helper.pkb | 5 ++++- source/reporters/ut_teamcity_reporter_helper.pks | 2 +- source/reporters/ut_tfs_junit_reporter.tpb | 6 ++++++ test/ut3_user/reporters.pkb | 2 +- test/ut3_user/reporters/test_documentation_reporter.pkb | 2 +- test/ut3_user/reporters/test_junit_reporter.pkb | 4 +++- 8 files changed, 24 insertions(+), 7 deletions(-) diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index 94ea5c5e6..44affa030 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -44,7 +44,13 @@ create or replace type body ut_junit_reporter is ' status="' || ut_utils.test_result_to_char(a_test.result) || '"' end || '>' ); if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, '' ); + if a_test.disabled_reason is not null then + ut_utils.append_to_list( l_results, '' ); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.disabled_reason ) ); + ut_utils.append_to_list( l_results, '' ); + else + ut_utils.append_to_list( l_results, '' ); + end if; end if; if a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); diff --git a/source/reporters/ut_teamcity_reporter.tpb b/source/reporters/ut_teamcity_reporter.tpb index 3e1a4bcf8..95bea32b8 100644 --- a/source/reporters/ut_teamcity_reporter.tpb +++ b/source/reporters/ut_teamcity_reporter.tpb @@ -84,7 +84,7 @@ create or replace type body ut_teamcity_reporter is lower(a_test.item.procedure_name); if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, ut_teamcity_reporter_helper.test_disabled(l_test_full_name)); + ut_utils.append_to_list( l_results, ut_teamcity_reporter_helper.test_disabled(l_test_full_name,a_test.disabled_reason)); else ut_utils.append_to_list( l_results, a_test.get_serveroutputs()); diff --git a/source/reporters/ut_teamcity_reporter_helper.pkb b/source/reporters/ut_teamcity_reporter_helper.pkb index 3a4679cb4..84a9d19e8 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pkb +++ b/source/reporters/ut_teamcity_reporter_helper.pkb @@ -89,10 +89,13 @@ create or replace package body ut_teamcity_reporter_helper is return message('testFinished', l_props); end; - function test_disabled(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2 is + function test_disabled(a_test_name varchar2,a_msg varchar2 default null, a_flow_id varchar2 default null) return varchar2 is l_props t_props; begin l_props('name') := a_test_name; + if a_msg is not null then + l_props('message') := a_msg; + end if; l_props('flowId') := a_flow_id; return message('testIgnored', l_props); end; diff --git a/source/reporters/ut_teamcity_reporter_helper.pks b/source/reporters/ut_teamcity_reporter_helper.pks index d94099411..d7fa86cdc 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pks +++ b/source/reporters/ut_teamcity_reporter_helper.pks @@ -21,7 +21,7 @@ create or replace package ut_teamcity_reporter_helper is function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2; function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2; - function test_disabled(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2; + function test_disabled(a_test_name varchar2,a_msg varchar2 default null, a_flow_id varchar2 default null) return varchar2; function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2; function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2; diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index e14af1d4d..710c3bc7f 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -69,6 +69,12 @@ create or replace type body ut_tfs_junit_reporter is ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); ut_utils.append_to_list( l_results, ''); -- Do not count error as failure + elsif a_test.result = ut_utils.gc_disabled then + if a_test.disabled_reason is not null then + ut_utils.append_to_list( l_results, ''); + else + ut_utils.append_to_list( l_results, '' ); + end if; elsif a_test.result = ut_utils.gc_failure then ut_utils.append_to_list( l_results, ''); ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) ); diff --git a/test/ut3_user/reporters.pkb b/test/ut3_user/reporters.pkb index edd26189c..d33adce23 100644 --- a/test/ut3_user/reporters.pkb +++ b/test/ut3_user/reporters.pkb @@ -35,7 +35,7 @@ as procedure erroring_test; --%test(a disabled test) - --%disabled + --%disabled(Disabled for testing purpose) procedure disabled_test; --%aftereach diff --git a/test/ut3_user/reporters/test_documentation_reporter.pkb b/test/ut3_user/reporters/test_documentation_reporter.pkb index 03759fe6a..4d44d2f63 100644 --- a/test/ut3_user/reporters/test_documentation_reporter.pkb +++ b/test/ut3_user/reporters/test_documentation_reporter.pkb @@ -24,7 +24,7 @@ create or replace package body test_documentation_reporter as - a disabled test [0 sec] (DISABLED) + a disabled test [0 sec] (DISABLED - Disabled for testing purpose) % Failures: diff --git a/test/ut3_user/reporters/test_junit_reporter.pkb b/test/ut3_user/reporters/test_junit_reporter.pkb index 8f015e80b..24012f6bb 100644 --- a/test/ut3_user/reporters/test_junit_reporter.pkb +++ b/test/ut3_user/reporters/test_junit_reporter.pkb @@ -249,7 +249,9 @@ create or replace package body test_junit_reporter as - + + + From 2ea9a53d3bc67588ffa0b1078deb141695833ad1 Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Mon, 7 Feb 2022 13:41:41 +0000 Subject: [PATCH 5/7] Updates to junit xsd --- .github/scripts/xsd/junit_windy.xsd | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/scripts/xsd/junit_windy.xsd b/.github/scripts/xsd/junit_windy.xsd index fe134662a..320779edd 100644 --- a/.github/scripts/xsd/junit_windy.xsd +++ b/.github/scripts/xsd/junit_windy.xsd @@ -1,6 +1,6 @@ - - @@ -71,10 +71,11 @@ Permission to waive conditions of this license may be requested from Windy Road - - - Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace - + + + + Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace + @@ -93,9 +94,9 @@ Permission to waive conditions of this license may be requested from Windy Road - - Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace - + + Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace + @@ -192,6 +193,11 @@ Permission to waive conditions of this license may be requested from Windy Road The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. + + + The total number of ignored or skipped tests in the suite. + + Time taken (in seconds) to execute the tests in the suite @@ -203,4 +209,4 @@ Permission to waive conditions of this license may be requested from Windy Road - + \ No newline at end of file From 78cfb830176d5eb0d6456f4c83244586225b4b3e Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Mon, 7 Feb 2022 14:19:48 +0000 Subject: [PATCH 6/7] Update coverage --- test/ut3_user/reporters.pkb | 11 +++++++++++ .../reporters/test_documentation_reporter.pkb | 3 ++- test/ut3_user/reporters/test_junit_reporter.pkb | 17 +++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/test/ut3_user/reporters.pkb b/test/ut3_user/reporters.pkb index d33adce23..76d345a3d 100644 --- a/test/ut3_user/reporters.pkb +++ b/test/ut3_user/reporters.pkb @@ -38,6 +38,10 @@ as --%disabled(Disabled for testing purpose) procedure disabled_test; + --%test(a disabled test with no reason) + --%disabled + procedure disabled_test_no_reason; + --%aftereach procedure aftereach; @@ -100,6 +104,13 @@ as ut3_develop.ut.expect(1,'this should not execute').to_equal(1); end; + procedure disabled_test_no_reason + is + begin + dbms_output.put_line(''); + ut3_develop.ut.expect(1,'this should not execute').to_equal(1); + end; + procedure beforeall is begin dbms_output.put_line(''); diff --git a/test/ut3_user/reporters/test_documentation_reporter.pkb b/test/ut3_user/reporters/test_documentation_reporter.pkb index 4d44d2f63..a627d26b4 100644 --- a/test/ut3_user/reporters/test_documentation_reporter.pkb +++ b/test/ut3_user/reporters/test_documentation_reporter.pkb @@ -25,6 +25,7 @@ create or replace package body test_documentation_reporter as a disabled test [0 sec] (DISABLED - Disabled for testing purpose) + a disabled test with no reason [0 sec] (DISABLED) % Failures: @@ -40,7 +41,7 @@ Failures: ORA-06512: at "UT3$USER#.TEST_REPORTERS", line 44% ORA-06512: at line 6 Finished in % seconds -4 tests, 1 failed, 1 errored, 1 disabled, 0 warning(s)%]'; +5 tests, 1 failed, 1 errored, 2 disabled, 0 warning(s)%]'; begin select * diff --git a/test/ut3_user/reporters/test_junit_reporter.pkb b/test/ut3_user/reporters/test_junit_reporter.pkb index 24012f6bb..4a574591c 100644 --- a/test/ut3_user/reporters/test_junit_reporter.pkb +++ b/test/ut3_user/reporters/test_junit_reporter.pkb @@ -219,12 +219,12 @@ create or replace package body test_junit_reporter as l_results ut3_develop.ut_varchar2_list; l_actual clob; l_expected varchar2(32767):=q'[ - - - - - - + + + + + + % @@ -255,6 +255,11 @@ create or replace package body test_junit_reporter as + + + + + % From c762920238473c1792fa1163e6e5f25724c89021 Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Tue, 8 Feb 2022 10:06:14 +0000 Subject: [PATCH 7/7] Update sonar --- source/reporters/ut_sonar_test_reporter.tpb | 2 +- test/ut3_user/reporters/test_sonar_test_reporter.pkb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index 8b043832a..20624fae9 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -47,7 +47,7 @@ create or replace type body ut_sonar_test_reporter is begin ut_utils.append_to_list( l_results, ''); if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ''); elsif a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); diff --git a/test/ut3_user/reporters/test_sonar_test_reporter.pkb b/test/ut3_user/reporters/test_sonar_test_reporter.pkb index 5821b2071..7c30fd91d 100644 --- a/test/ut3_user/reporters/test_sonar_test_reporter.pkb +++ b/test/ut3_user/reporters/test_sonar_test_reporter.pkb @@ -9,7 +9,8 @@ create or replace package body test_sonar_test_reporter as % %%% %%% -%% +%% +%% ]';