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

Skip to content

Commit e0b220d

Browse files
authored
Merge branch 'develop' into feature/12cblockcoverage
2 parents 8dbb1a1 + a62c9ce commit e0b220d

25 files changed

Lines changed: 365 additions & 119 deletions

.travis/install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ SQL
2929
set feedback off
3030
@create_utplsql_owner.sql $UT3_TESTER $UT3_TESTER_PASSWORD $UT3_TABLESPACE
3131
32+
--needed for testing distributed transactions
33+
grant create public database link to $UT3_TESTER;
34+
grant drop public database link to $UT3_TESTER;
3235
set feedback on
3336
--Needed for testing coverage outside of main UT3 schema.
3437
grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, select any dictionary to $UT3_TESTER;
3538
revoke execute on dbms_crypto from $UT3_TESTER;
39+
grant create job to $UT3_TESTER;
3640
exit
3741
SQL

docs/userguide/annotations.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ end test_pkg;
108108

109109
| Annotation |Level| Description |
110110
| --- | --- | --- |
111-
| `%suite(<description>)` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). |
112-
| `%suitepath(<path>)` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. |
113-
| `%displayname(<description>)` | Package/procedure | Human-readable and meaningful description of a suite/test. `%displayname(Name of the suite/test)`. The annotation is provided for flexibility and convenience only. It has exactly the same meaning as `<description>` in `test` and `suite` annotations. If description is provided using both `suite`/`test` and `displayname`, then the one defined as last takes precedence. |
114-
| `%test(<description>)` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). |
115-
| `%throws(<exception_number>[,<exception_number>[,...]])`| Procedure | Denotes that the annotated procedure must throw one of the exception numbers provided. If no valid numbers were provided as annotation parameters the annotation is ignored. Applicable to test procedures only. |
116-
| `%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. |
117-
| `%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. |
118-
| `%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. |
119-
| `%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. |
120-
| `%beforetest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. |
121-
| `%aftertest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. |
122-
| `%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) |
123-
| `%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. |
111+
| `--%suite(<description>)` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). |
112+
| `--%suitepath(<path>)` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. |
113+
| `--%displayname(<description>)` | Package/procedure | Human-readable and meaningful description of a suite/test. `%displayname(Name of the suite/test)`. The annotation is provided for flexibility and convenience only. It has exactly the same meaning as `<description>` in `test` and `suite` annotations. If description is provided using both `suite`/`test` and `displayname`, then the one defined as last takes precedence. |
114+
| `--%test(<description>)` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). |
115+
| `--%throws(<exception_number>[,<exception_number>[,...]])`| Procedure | Denotes that the annotated procedure must throw one of the exception numbers provided. If no valid numbers were provided as annotation parameters the annotation is ignored. Applicable to test procedures only. |
116+
| `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. |
117+
| `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. |
118+
| `--%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. |
119+
| `--%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. |
120+
| `--%beforetest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. |
121+
| `--%aftertest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. |
122+
| `--%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) |
123+
| `--%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. |
124124

125125
# Suitepath concept
126126

docs/userguide/expectations.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ end;
165165
## be_empty
166166
Unary matcher that validates if the provided dataset is empty.
167167

168-
Can be used with `refcursor` or `table type`
168+
Can be used with `refcursor` or `nested table`/`varray` passed as `ANYDATA`
169169

170170
Usage:
171171
```sql
@@ -179,7 +179,16 @@ begin
179179
end;
180180
```
181181

182-
When used with anydata, it is only valid for collection data types.
182+
```sql
183+
procedure test_if_cursor_is_empty is
184+
l_data ut_varchar2_list;
185+
begin
186+
l_data := ut_varchar2_list();
187+
ut.expect( anydata.convertCollection( l_data ) ).to_be_empty();
188+
--or
189+
ut.expect( anydata.convertCollection( l_data ) ).to_( be_empty() );
190+
end;
191+
```
183192

184193
## be_false
185194
Unary matcher that validates if the provided value is false.
@@ -420,7 +429,7 @@ The `a_nulls_are_equal` parameter controls the behavior of a `null = null` compa
420429
To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal => false` to the `equal` matcher.
421430

422431

423-
## Comparing objects, cursors, collections of data
432+
## Comparing cursors, object types, nested tables and varrays
424433

425434
utPLSQL is capable of comparing compound data-types including:
426435
- ref cursors
@@ -434,7 +443,7 @@ utPLSQL is capable of comparing compound data-types including:
434443
- Comparison of cursor columns containing `DATE` will only compare date part **and ignore time** by default. See [Comparing cursor data containing DATE fields](#comparing-cursor-data-containing-date-fields) to check how to enable date-time comparison in cursors.
435444
- To compare nested table/varray type you need to convert it to `anydata` by using `anydata.convertCollection()`
436445
- To compare object type you need to convert it to `anydata` by using `anydata.convertObject()`
437-
- It is possible to compare PL/SQL records and nested tables/varrays/associative arrays of PL/SQL records. To compare this types of data, use cursor comparison feature of utPLSQL and TABLE operator in SQL query
446+
- It is possible to compare PL/SQL records, collections, varrays and associative arrays. To compare this types of data, use cursor comparison feature of utPLSQL and TABLE operator in SQL query
438447
- On Oracle 11g Release 2 - pipelined table functions are needed (see section [Implicit (Shadow) Types in this artcile](https://oracle-base.com/articles/misc/pipelined-table-functions))
439448
- On Oracle 12c and above - use [TABLE function on nested tables/varrays/associative arrays of PL/SQL records](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1)
440449

@@ -448,7 +457,7 @@ For details on available options and how to use them, read the [advanced data co
448457

449458
### Diff functionality for compound data-types
450459

451-
When comparing compound data, utPLSQL will determine diff between expected and actual data.
460+
When comparing compound data, utPLSQL will determine the difference between the expected and the actual data.
452461
The diff includes:
453462
- differences in column names, column positions and column data-type for cursor data
454463
- only data in columns/rows that differ
@@ -473,16 +482,16 @@ And the actual cursor data:
473482
| M | LUKE | SKYWALKER | 1000 | 2 |
474483

475484

476-
When considering the data-sets as ordered, there are following following differences:
485+
The two datasets above have the following differences:
477486
- column ID is misplaced (should be first column but is last)
478487
- column SALARY has data-type VARCHAR2 but should be NUMBER
479-
- column GENDER exists in actual but not in the expected (it ir an Extra column)
488+
- column GENDER exists in actual but not in the expected (it is an Extra column)
480489
- data in column SALARY for row number 1 in actual is not matching expected
481490
- row number 2 in actual (ID=3) is not matching expected
482491
- row number 3 in actual (ID=4) is not matching expected
483492
- row number 4 in actual (ID=2) is not expected in results (Extra row in actual)
484493

485-
utPLSQL will report all of the above differences in a readable format to help you identify what is not correct in compared data-set.
494+
utPLSQL will report all of the above differences in a readable format to help you identify what is not correct in the compared dataset.
486495

487496
Below example illustrates, how utPLSQL will report such differences.
488497
```sql
@@ -562,22 +571,22 @@ utPLSQL identifies and reports on columns:
562571
- extra/missing columns
563572

564573
When comparing rows utPLSQL:
565-
- reports only mismatched columns, when rows match
574+
- reports only mismatched columns when rows match
566575
- reports columns existing in both data-sets when whole row is not matching
567-
- reports whole extra (not expected) row from actual, when actual has extra rows
568-
- reports whole missing (expected) row from expected, when expected has extra rows
576+
- reports whole extra (not expected) row from actual when actual has extra rows
577+
- reports whole missing (expected) row from expected when expected has extra rows
569578

570579

571-
### Object and collection data-type comparison examples
580+
### Object and nested table data-type comparison examples
572581

573-
When comparing object type to object type or collection to collection, utPLSQL will check:
582+
When comparing object type / nested table / varray, utPLSQL will check:
574583
- if data-types match
575-
- id data in the compared objects/collections are the same.
584+
- if data in the compared elements is the same.
576585

577-
The diff functionality for objects and collections is similar to diff on cursors.
578-
When diffing objects/collections however, utPLSQL will not check attribute names and data-types.
586+
The diff functionality for objects / nested tables / varrays is similar to diff on cursors.
587+
When diffing, utPLSQL will not check name and data-type of individual attribute as the type itself defines the underlying structure.
579588

580-
Below examples demonstrate how to compare object and collection data-types.
589+
Below examples demonstrate how to compare object and nested table data-types.
581590

582591
Object type comparison.
583592
```sql
@@ -589,7 +598,7 @@ begin
589598
end;
590599
/
591600
create or replace package demo_dept as
592-
-- %suite(demo)
601+
--%suite(demo)
593602

594603
--%test(demo of object to object comparison)
595604
procedure test_department;
@@ -626,7 +635,7 @@ begin
626635
end;
627636
/
628637
create or replace package demo_depts as
629-
-- %suite(demo)
638+
--%suite(demo)
630639

631640
--%test(demo of collection comparison)
632641
procedure test_departments;
@@ -773,19 +782,21 @@ The matrix below illustrates the data types supported by different matchers.
773782

774783
| | be_between | be_empty | be_false | be_greater_than | be_greater_or_equal | be_less_or_equal | be_less_than | be_like | be_not_null | be_null | be_true | equal | have_count | match |
775784
|:------------------------------|:----------:|:--------:|:--------:|:---------------:|:-------------------:|:----------------:|:------------:|:-------:|:-----------:|:-------:|:-------:|:-----:|:----------:|:-----:|
776-
| anydata( collection, object ) | | X | | | | | | | X | X | | X | X | |
777785
| blob | | | | | | | | | X | X | | X | | |
778786
| boolean | | | X | | | | | | X | X | X | X | | |
779787
| clob | | | | | | | | X | X | X | | X | | X |
780788
| date | X | | | X | X | X | X | | X | X | | X | | |
781789
| number | X | | | X | X | X | X | | X | X | | X | | |
782-
| refcursor | | X | | | | | | | X | X | | X | X | |
783790
| timestamp | X | | | X | X | X | X | | X | X | | X | | |
784791
| timestamp with timezone | X | | | X | X | X | X | | X | X | | X | | |
785792
| timestamp with local timezone | X | | | X | X | X | X | | X | X | | X | | |
786793
| varchar2 | X | | | | | | | X | X | X | | X | | X |
787794
| interval year to month | X | | | X | X | X | X | | X | X | | X | | |
788795
| interval day to second | X | | | X | X | X | X | | X | X | | X | | |
796+
| refcursor | | X | | | | | | | X | X | | X | X | |
797+
| nested table (as anydata) | | X | | | | | | | X | X | | X | X | |
798+
| varray (as anydata) | | X | | | | | | | X | X | | X | X | |
799+
| object (as anydata) | | | | | | | | | X | X | | X | | |
789800

790801

791802

docs/userguide/getting-started.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This way, we assure we don't jump ahead too much and produce code that is untest
2525
```sql
2626
create or replace package test_betwnstr as
2727

28-
-- %suite(Between string function)
28+
--%suite(Between string function)
2929

3030
end;
3131
/
@@ -46,9 +46,9 @@ Finished in .451423 seconds
4646
```sql
4747
create or replace package test_betwnstr as
4848

49-
-- %suite(Between string function)
49+
--%suite(Between string function)
5050

51-
-- %test(Returns substring from start position to end position)
51+
--%test(Returns substring from start position to end position)
5252
procedure basic_usage;
5353

5454
end;
@@ -201,12 +201,12 @@ A new requirement was added:
201201
```sql
202202
create or replace package test_betwnstr as
203203

204-
-- %suite(Between string function)
204+
--%suite(Between string function)
205205

206-
-- %test(Returns substring from start position to end position)
206+
--%test(Returns substring from start position to end position)
207207
procedure basic_usage;
208208

209-
-- %test(Returns substring when start position is zero)
209+
--%test(Returns substring when start position is zero)
210210
procedure zero_start_position;
211211

212212
end;

source/api/ut.pkb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ create or replace package body ut is
9494
ut_expectation_processor.report_failure(a_message);
9595
end;
9696

97+
procedure raise_if_packages_invalidated is
98+
e_package_invalidated exception;
99+
pragma exception_init (e_package_invalidated, -04068);
100+
begin
101+
if ut_expectation_processor.invalidation_exception_found() then
102+
ut_expectation_processor.reset_invalidation_exception();
103+
raise e_package_invalidated;
104+
end if;
105+
end;
106+
97107
procedure run_autonomous(
98108
a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
99109
a_coverage_schemes ut_varchar2_list := null,a_coverage_type varchar2:=null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
@@ -149,6 +159,8 @@ create or replace package body ut is
149159
end loop;
150160
close l_lines;
151161
end if;
162+
raise_if_packages_invalidated();
163+
return;
152164
end;
153165

154166
function run(
@@ -174,6 +186,8 @@ create or replace package body ut is
174186
end loop;
175187
close l_lines;
176188
end if;
189+
raise_if_packages_invalidated();
190+
return;
177191
end;
178192

179193
function run(
@@ -198,6 +212,8 @@ create or replace package body ut is
198212
end loop;
199213
close l_lines;
200214
end if;
215+
raise_if_packages_invalidated();
216+
return;
201217
end;
202218

203219
function run(
@@ -222,6 +238,8 @@ create or replace package body ut is
222238
end loop;
223239
close l_lines;
224240
end if;
241+
raise_if_packages_invalidated();
242+
return;
225243
end;
226244

227245
function run(
@@ -247,6 +265,8 @@ create or replace package body ut is
247265
end loop;
248266
close l_lines;
249267
end if;
268+
raise_if_packages_invalidated();
269+
return;
250270
end;
251271

252272
function run(
@@ -272,6 +292,8 @@ create or replace package body ut is
272292
end loop;
273293
close l_lines;
274294
end if;
295+
raise_if_packages_invalidated();
296+
return;
275297
end;
276298

277299
procedure run(
@@ -288,6 +310,7 @@ create or replace package body ut is
288310
if l_reporter is of (ut_output_reporter_base) then
289311
treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output();
290312
end if;
313+
raise_if_packages_invalidated();
291314
end;
292315

293316
procedure run(
@@ -304,6 +327,7 @@ create or replace package body ut is
304327
if l_reporter is of (ut_output_reporter_base) then
305328
treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output();
306329
end if;
330+
raise_if_packages_invalidated();
307331
end;
308332

309333
procedure run(

0 commit comments

Comments
 (0)