Skip to content

Commit dc0b4a6

Browse files
committed
Addressing changes via PR review.
1 parent 01e5364 commit dc0b4a6

File tree

5 files changed

+75
-83
lines changed

5 files changed

+75
-83
lines changed

docs/userguide/annotations.md

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,46 +1617,8 @@ or
16171617
Tags are defined as a comma separated list within the `--%tags` annotation.
16181618

16191619
When a suite/context is tagged, all of its children will automatically inherit the tag and get executed along with the parent, unless they are excluded explicitly at runtime with a negated tag expression.
1620-
Parent suite tests are not executed, but a suitepath hierarchy is kept.
1620+
See [running unit tests](running-unit-tests.md) for more information on using tags to filter test suites that are to be executed.
16211621

1622-
Sample test suite package with tags.
1623-
```sql linenums="1"
1624-
create or replace package ut_sample_test is
1625-
1626-
--%suite(Sample Test Suite)
1627-
--%tags(api)
1628-
1629-
--%test(Compare Ref Cursors)
1630-
--%tags(complex,fast)
1631-
procedure ut_refcursors1;
1632-
1633-
--%test(Run equality test)
1634-
--%tags(simple,fast)
1635-
procedure ut_test;
1636-
1637-
end ut_sample_test;
1638-
/
1639-
1640-
create or replace package body ut_sample_test is
1641-
1642-
procedure ut_refcursors1 is
1643-
v_actual sys_refcursor;
1644-
v_expected sys_refcursor;
1645-
begin
1646-
open v_expected for select 1 as test from dual;
1647-
open v_actual for select 2 as test from dual;
1648-
1649-
ut.expect(v_actual).to_equal(v_expected);
1650-
end;
1651-
1652-
procedure ut_test is
1653-
begin
1654-
ut.expect(1).to_equal(0);
1655-
end;
1656-
1657-
end ut_sample_test;
1658-
/
1659-
```
16601622
#### Tag naming convention
16611623

16621624
Tags must follow the below naming convention:

docs/userguide/running-unit-tests.md

Lines changed: 68 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Multiple tags are separated by comma.
323323

324324
### Tag Expressions
325325

326-
Tag expressions are boolean expressions with the operators !, & and |. In addition, ( and ) can be used to adjust for operator precedence.
326+
Tag expressions are boolean expressions created by combining tags with the `!`, `&`, `|` operators. Tag expressions can be grouped using `(` and `)` braces. Grouping tag expressions affects operator precedence.
327327

328328
| Operator | Meaning |
329329
| -------- | --------|
@@ -338,28 +338,86 @@ If you are tagging your tests across multiple dimensions, tag expressions help y
338338
| -------- | --------|
339339
| product | all tests for product |
340340
| catalog \| shipping | all tests for catalog plus all tests for shipping |
341-
| catalog & shipping | all tests for the intersection between catalog and shipping |
342-
| product & !end-to-end | all tests for product, but not the end-to-end tests |
341+
| catalog & shipping | all tests that are tagged with both `catalog` and `shipping` tags |
342+
| product & !end-to-end | all tests tagged `product`, except the tests tagged `end-to-end` |
343343
| (micro \| integration) & (product \| shipping) | all micro or integration tests for product or shipping |
344344

345345

346-
Execution of the test is done by using the parameter `a_tags` with tag expressions
346+
Taking the last expression above `(micro | integration) & (product | shipping)`
347347

348+
| --%tags |included in run |
349+
| -------- | --------|
350+
| micro | no |
351+
| integration | no |
352+
| micro | no |
353+
| product | no |
354+
| shipping | no |
355+
| micro | no |
356+
| micro, integration | no |
357+
| product, shipping | no |
358+
| micro, product | yes |
359+
| micro, shipping | yes |
360+
| integration, product | yes |
361+
| integration, shipping | yes |
362+
| integration, micro, shipping | yes |
363+
| integration, micro, product | yes |
364+
| integration, shipping ,product | yes |
365+
| micro, shipping ,product | yes |
366+
| integration, micro, shipping ,product | yes |
367+
368+
369+
### Sample execution of test with tags.
370+
371+
Execution of the test with tag expressions is done using the parameter `a_tags`.
372+
Given a test package `ut_sample_test` defined below
348373

349374
```sql linenums="1"
350-
select * from table(ut.run(a_tags => 'fast|!complex'));
375+
create or replace package ut_sample_test is
376+
377+
--%suite(Sample Test Suite)
378+
--%tags(api)
379+
380+
--%test(Compare Ref Cursors)
381+
--%tags(complex,fast)
382+
procedure ut_refcursors1;
383+
384+
--%test(Run equality test)
385+
--%tags(simple,fast)
386+
procedure ut_test;
387+
388+
end ut_sample_test;
389+
/
390+
391+
create or replace package body ut_sample_test is
392+
393+
procedure ut_refcursors1 is
394+
v_actual sys_refcursor;
395+
v_expected sys_refcursor;
396+
begin
397+
open v_expected for select 1 as test from dual;
398+
open v_actual for select 2 as test from dual;
399+
400+
ut.expect(v_actual).to_equal(v_expected);
401+
end;
402+
403+
procedure ut_test is
404+
begin
405+
ut.expect(1).to_equal(0);
406+
end;
407+
408+
end ut_sample_test;
409+
/
351410
```
352-
The above call will execute all tests from `ut_sample_test` package as the whole suite is tagged with `api` because a suite meet expression condition.
353411

354412
```sql linenums="1"
355413
select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'api'));
356414
```
357415
The above call will execute all tests from `ut_sample_test` package as the whole suite is tagged with `api`
358416

359417
```sql linenums="1"
360-
select * from table(ut.run(a_tags => 'complex'));
418+
select * from table(ut.run(a_tags => 'fast&complex'));
361419
```
362-
The above call will execute only the `ut_sample_test.ut_refcursors1` test, as only the test `ut_refcursors1` is tagged with `complex`
420+
The above call will execute only the `ut_sample_test.ut_refcursors1` test, as only the test `ut_refcursors1` is tagged with `complex` and `fast`
363421

364422
```sql linenums="1"
365423
select * from table(ut.run(a_tags => 'fast'));
@@ -376,25 +434,13 @@ Examples (based on above sample test suite)
376434
select * from table(ut.run(a_tags => '(api|fast)&!complex'));
377435
```
378436

379-
which is equivalent of legacy calling:
380-
381-
```sql linenums="1"
382-
select * from table(ut.run(a_tags => 'api,fast,-complex'));
383-
```
384-
385437
or
386438

387439
```sql linenums="1"
388-
select * from table(ut.run(a_tags => '(api|fast)&(!complex&!test1)'));
389-
```
390-
391-
which is equivalent of legacy calling:
392-
393-
```sql linenums="1"
394-
select * from table(ut.run(a_tags => 'api,fast,-complex,-test1'));
440+
select * from table(ut.run(a_tags => '(api|fast)&!complex&!test1'));
395441
```
396442

397-
The above call will execute all suites/contexts/tests that are marked with any of tags `api` or `fast` except those suites/contexts/tests that are marked as `complex`.
443+
The above call will execute all suites/contexts/tests that are marked with any of tags `api` or `fast` except those suites/contexts/tests that are marked as `complex` and except those suites/contexts/tests that are marked as `test1`.
398444
Given the above example package `ut_sample_test`, only `ut_sample_test.ut_test` will be executed.
399445

400446

source/core/ut_suite_cache_manager.pkb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,6 @@ create or replace package body ut_suite_cache_manager is
285285
return l_results;
286286
end;
287287

288-
function get_cached_suites(
289-
a_schema_paths ut_path_items,
290-
a_random_seed positive := null
291-
) return ut_suite_cache_rows is
292-
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
293-
l_schema_paths ut_path_items;
294-
begin
295-
l_schema_paths := a_schema_paths;
296-
l_suite_items := get_suite_items(a_schema_paths);
297-
return l_suite_items;
298-
end;
299-
300288
function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is
301289
l_cache_parse_time timestamp;
302290
begin
@@ -443,7 +431,7 @@ create or replace package body ut_suite_cache_manager is
443431
a_schema_paths ut_path_items
444432
) return ut_suite_cache_rows is
445433
begin
446-
return get_cached_suite_rows(get_cached_suites( a_schema_paths ));
434+
return get_cached_suite_rows(get_suite_items(a_schema_paths));
447435
end;
448436

449437
function get_suite_items_info(

source/core/ut_suite_cache_manager.pks

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ create or replace package ut_suite_cache_manager authid definer is
5858
a_suites_filtered ut_suite_cache_rows
5959
) return ut_suite_cache_rows;
6060

61-
function get_cached_suites(
62-
a_schema_paths ut_path_items,
63-
a_random_seed positive := null
64-
) return ut_suite_cache_rows;
65-
6661
function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items;
6762

6863
/*
@@ -77,6 +72,10 @@ create or replace package ut_suite_cache_manager authid definer is
7772
function get_suite_items_info(
7873
a_suite_cache_items ut_suite_cache_rows
7974
) return ut_suite_items_info;
75+
76+
function get_suite_items (
77+
a_schema_paths ut_path_items
78+
) return ut_suite_cache_rows;
8079

8180
/*
8281
* Retrieves list of cached suite packages.

source/core/ut_suite_manager.pkb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,7 @@ create or replace package body ut_suite_manager is
360360
l_filtered_rows ut_suite_cache_rows;
361361
l_result t_cached_suites_cursor;
362362
begin
363-
l_unfiltered_rows := ut_suite_cache_manager.get_cached_suites(
364-
a_schema_paths,
365-
a_random_seed
366-
);
363+
l_unfiltered_rows := ut_suite_cache_manager.get_suite_items(a_schema_paths);
367364

368365
l_tag_filter_applied := ut_suite_tag_filter.apply(l_unfiltered_rows,a_tags);
369366
l_filtered_rows := get_filtered_cursor(ut_suite_cache_manager.get_cached_suite_rows(l_tag_filter_applied),a_skip_all_objects);

0 commit comments

Comments
 (0)