Skip to content

Commit 62716ae

Browse files
authored
Merge pull request #1183 from utPLSQL/feature/add_reason_to_disable
Feature/add reason to disable
2 parents 82ac7f4 + c762920 commit 62716ae

32 files changed

+701
-70
lines changed

.github/scripts/xsd/junit_windy.xsd

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
2+
<xs:schema
3+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
44
elementFormDefault="qualified"
55
attributeFormDefault="unqualified">
66
<xs:annotation>
@@ -71,10 +71,11 @@ Permission to waive conditions of this license may be requested from Windy Road
7171
<xs:element name="testcase" minOccurs="0" maxOccurs="unbounded">
7272
<xs:complexType>
7373
<xs:choice minOccurs="0">
74-
<xs:element name="error">
75-
<xs:annotation>
76-
<xs:documentation xml:lang="en">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</xs:documentation>
77-
</xs:annotation>
74+
<xs:element name="skipped" />
75+
<xs:element name="error" minOccurs="0" maxOccurs="1">
76+
<xs:annotation>
77+
<xs:documentation xml:lang="en">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</xs:documentation>
78+
</xs:annotation>
7879
<xs:complexType>
7980
<xs:simpleContent>
8081
<xs:extension base="pre-string">
@@ -93,9 +94,9 @@ Permission to waive conditions of this license may be requested from Windy Road
9394
</xs:complexType>
9495
</xs:element>
9596
<xs:element name="failure">
96-
<xs:annotation>
97-
<xs:documentation xml:lang="en">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</xs:documentation>
98-
</xs:annotation>
97+
<xs:annotation>
98+
<xs:documentation xml:lang="en">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</xs:documentation>
99+
</xs:annotation>
99100
<xs:complexType>
100101
<xs:simpleContent>
101102
<xs:extension base="pre-string">
@@ -192,6 +193,11 @@ Permission to waive conditions of this license may be requested from Windy Road
192193
<xs:documentation xml:lang="en">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.</xs:documentation>
193194
</xs:annotation>
194195
</xs:attribute>
196+
<xs:attribute name="skipped" type="xs:int" use="optional">
197+
<xs:annotation>
198+
<xs:documentation xml:lang="en">The total number of ignored or skipped tests in the suite.</xs:documentation>
199+
</xs:annotation>
200+
</xs:attribute>
195201
<xs:attribute name="time" type="xs:decimal" use="required">
196202
<xs:annotation>
197203
<xs:documentation xml:lang="en">Time taken (in seconds) to execute the tests in the suite</xs:documentation>
@@ -203,4 +209,4 @@ Permission to waive conditions of this license may be requested from Windy Road
203209
<xs:whiteSpace value="preserve"/>
204210
</xs:restriction>
205211
</xs:simpleType>
206-
</xs:schema>
212+
</xs:schema>

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,

0 commit comments

Comments
 (0)