Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 987d391

Browse files
committed
Update code.
1 parent e358037 commit 987d391

21 files changed

Lines changed: 685 additions & 45 deletions

docs/userguide/annotations.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ end;
140140
| `--%beforetest([[<owner>.]<package>.]<procedure>[,...])` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. |
141141
| `--%aftertest([[<owner>.]<package>.]<procedure>[,...])` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. |
142142
| `--%rollback(<type>)` | 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) |
143-
| `--%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. |
143+
| `--%disabled(<reason>)` | 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 |
144144
| `--%context(<description>)` | Package | Denotes start of a named context (sub-suite) in a suite package an optional description for context can be provided. |
145145
| `--%name(<name>)` | Package | Denotes name for a context. Must be placed after the context annotation and before start of nested context. |
146146
| `--%endcontext` | Package | Denotes end of a nested context (sub-suite) in a suite package |
@@ -343,12 +343,13 @@ Finished in .008815 seconds
343343

344344
### Disabled
345345
Marks annotated suite package or test procedure as disabled.
346+
You can provide the reason why the test is disabled that will be displayed in output.
346347

347348
Disabling suite.
348349
```sql
349350
create or replace package test_package as
350351
--%suite(Tests for a package)
351-
--%disabled
352+
--%disabled(Reason for disabling suite)
352353

353354
--%test(Description of tested behavior)
354355
procedure some_test;
@@ -371,13 +372,58 @@ exec ut.run('test_package');
371372
```
372373
```
373374
Tests for a package
374-
Description of tested behavior [0 sec] (DISABLED)
375-
Description of another behavior [0 sec] (DISABLED)
375+
Description of tested behavior [0 sec] (DISABLED - Reason for disabling suite)
376+
Description of another behavior [0 sec] (DISABLED - Reason for disabling suite)
376377
377378
Finished in .001441 seconds
378379
2 tests, 0 failed, 0 errored, 2 disabled, 0 warning(s)
379380
```
380381

382+
Disabling the context(s).
383+
```sql
384+
create or replace package test_package as
385+
--%suite(Tests for a package)
386+
387+
--%context(Context1)
388+
389+
--%test(Description of tested behavior)
390+
procedure some_test;
391+
392+
--%endcontext
393+
394+
--%context(Context2)
395+
396+
--%disabled(Reason for disabling context2)
397+
398+
--%test(Description of another behavior)
399+
procedure other_test;
400+
401+
--%endcontext
402+
end;
403+
/
404+
create or replace package body test_package as
405+
406+
procedure some_test is begin null; end;
407+
408+
procedure other_test is begin null; end;
409+
end;
410+
/
411+
```
412+
413+
```sql
414+
exec ut.run('test_package');
415+
```
416+
```
417+
Tests for a package
418+
Context1
419+
Description of tested behavior [.002 sec]
420+
Context2
421+
Description of another behavior [0 sec] (DISABLED - Reason for disabling context2)
422+
423+
Finished in .005079 seconds
424+
2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s)
425+
```
426+
381427
Disabling individual test(s).
382428
```sql
383429
create or replace package test_package as
@@ -387,7 +433,7 @@ create or replace package test_package as
387433
procedure some_test;
388434

389435
--%test(Description of another behavior)
390-
--%disabled
436+
--%disabled(Reason for disabling test)
391437
procedure other_test;
392438
end;
393439
/
@@ -406,7 +452,7 @@ exec ut.run('test_package');
406452
```
407453
Tests for a package
408454
Description of tested behavior [.004 sec]
409-
Description of another behavior [0 sec] (DISABLED)
455+
Description of another behavior [0 sec] (DISABLED - Reason for disabling test)
410456
411457
Finished in .005868 seconds
412458
2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s)

source/api/ut_suite_item_info.tpb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ create or replace type body ut_suite_item_info is
1717
*/
1818
constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2,
1919
a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer,
20-
a_tags ut_varchar2_rows) return self as result is
20+
a_disabled_reason varchar2, a_tags ut_varchar2_rows) return self as result is
2121
begin
2222
self.object_owner := a_object_owner;
2323
self.object_name := a_object_name;
@@ -27,6 +27,10 @@ create or replace type body ut_suite_item_info is
2727
self.item_line_no := a_item_line_no;
2828
self.path := a_path;
2929
self.disabled_flag := a_disabled_flag;
30+
self.disabled_reason := case when
31+
a_disabled_flag = 1 then a_disabled_reason
32+
else null
33+
end;
3034
self.tags := case
3135
when a_tags is null then null
3236
when a_tags.count = 0 then null

source/api/ut_suite_item_info.tps

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ create or replace type ut_suite_item_info as object (
2323
item_line_no integer, -- line_number where annotation identifying the item exists
2424
path varchar2( 4000 ),-- suitepath of the item
2525
disabled_flag integer, -- 0 (zero) if item is not disabled, 1 if item is disabled by --%disabled annotation
26+
disabled_reason varchar2(4000), -- if disable flag is set then you can pass reason
2627
tags varchar2(4000),
2728
constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2,
2829
a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer,
29-
a_tags ut_varchar2_rows) return self as result
30+
a_disabled_reason varchar2, a_tags ut_varchar2_rows) return self as result
3031
)
3132
/

source/core/types/ut_logical_suite.tpb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ create or replace type body ut_logical_suite as
1616
limitations under the License.
1717
*/
1818

19-
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite) is
19+
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2) is
2020
begin
2121
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
2222
self.start_time := current_timestamp;
2323
for i in 1 .. self.items.count loop
24-
self.items(i).mark_as_skipped();
24+
self.items(i).mark_as_skipped(coalesce(a_skip_reason,self.disabled_reason));
2525
end loop;
2626
self.end_time := self.start_time;
2727
ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);

source/core/types/ut_logical_suite.tps

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace type ut_logical_suite under ut_suite_item (
1+
create or replace type ut_logical_suite force under ut_suite_item (
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2021 utPLSQL Project
@@ -21,7 +21,7 @@ create or replace type ut_logical_suite under ut_suite_item (
2121
*/
2222
items ut_suite_items,
2323

24-
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite),
24+
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2),
2525
overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false),
2626
overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean,
2727
overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite),

source/core/types/ut_run.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ create or replace type body ut_run as
3939
return;
4040
end;
4141

42-
overriding member procedure mark_as_skipped(self in out nocopy ut_run) is
42+
overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2) is
4343
begin
4444
null;
4545
end;

source/core/types/ut_run.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ create or replace type ut_run under ut_suite_item (
3636
a_random_test_order_seed positive := null,
3737
a_run_tags ut_varchar2_rows := null
3838
) return self as result,
39-
overriding member procedure mark_as_skipped(self in out nocopy ut_run),
39+
overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2),
4040
overriding member function do_execute(self in out nocopy ut_run) return boolean,
4141
overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false),
4242
overriding member procedure calc_execution_result(self in out nocopy ut_run),

source/core/types/ut_suite.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ create or replace type body ut_suite as
4444
ut_utils.debug_log('ut_suite.execute');
4545

4646
if self.get_disabled_flag() then
47-
self.mark_as_skipped();
47+
self.mark_as_skipped(a_skip_reason => self.disabled_reason);
4848
else
4949
self.start_time := current_timestamp;
5050
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);

source/core/types/ut_suite_cache_row.tps

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create type ut_suite_cache_row as object (
1+
create or replace type ut_suite_cache_row as object (
22
/*
33
utPLSQL - Version 3
44
Copyright 2016 - 2021 utPLSQL Project
@@ -26,6 +26,7 @@ create type ut_suite_cache_row as object (
2626
description varchar2(4000 byte),
2727
rollback_type number,
2828
disabled_flag number,
29+
disabled_reason varchar2(4000 byte),
2930
warnings ut_varchar2_rows,
3031
before_all_list ut_executables,
3132
after_all_list ut_executables,

source/core/types/ut_suite_item.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ create or replace type body ut_suite_item as
2626
self.line_no := a_line_no;
2727
self.transaction_invalidators := ut_varchar2_list();
2828
self.disabled_flag := ut_utils.boolean_to_int(false);
29+
self.disabled_reason := null;
2930
end;
3031

3132
member function get_disabled_flag return boolean is

0 commit comments

Comments
 (0)