You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/userguide/annotations.md
+10-78
Original file line number
Diff line number
Diff line change
@@ -1616,93 +1616,25 @@ or
1616
1616
1617
1617
Tags are defined as a comma separated list within the `--%tags` annotation.
1618
1618
1619
-
When executing a test run with tag filter applied, the framework will find all tests associated with the given tags and execute them.
1620
-
The framework applies `OR` logic to all specified tags so any test / suite that matches at least one tag will be included in the test run.
1621
-
1622
-
When a suite/context is tagged, all of its children will automatically inherit the tag and get executed along with the parent. Parent suite tests are not executed, but a suitepath hierarchy is kept.
1623
-
1624
-
1625
-
Sample test suite package with tags.
1626
-
```sql linenums="1"
1627
-
create or replace package ut_sample_test is
1628
-
1629
-
--%suite(Sample Test Suite)
1630
-
--%tags(api)
1631
-
1632
-
--%test(Compare Ref Cursors)
1633
-
--%tags(complex,fast)
1634
-
procedure ut_refcursors1;
1635
-
1636
-
--%test(Run equality test)
1637
-
--%tags(simple,fast)
1638
-
procedure ut_test;
1639
-
1640
-
end ut_sample_test;
1641
-
/
1642
-
1643
-
create or replace package body ut_sample_test is
1644
-
1645
-
procedure ut_refcursors1 is
1646
-
v_actual sys_refcursor;
1647
-
v_expected sys_refcursor;
1648
-
begin
1649
-
open v_expected for select1as test from dual;
1650
-
open v_actual for select2as test from dual;
1651
-
1652
-
ut.expect(v_actual).to_equal(v_expected);
1653
-
end;
1654
-
1655
-
procedure ut_test is
1656
-
begin
1657
-
ut.expect(1).to_equal(0);
1658
-
end;
1659
-
1660
-
end ut_sample_test;
1661
-
/
1662
-
```
1663
-
1664
-
Execution of the test is done by using the parameter `a_tags`
The above call will execute all tests from `ut_sample_test` package as the whole suite is tagged with `api`
1670
-
1671
-
```sql linenums="1"
1672
-
select*from table(ut.run(a_tags =>'complex'));
1673
-
```
1674
-
The above call will execute only the `ut_sample_test.ut_refcursors1` test, as only the test `ut_refcursors1` is tagged with `complex`
1675
-
1676
-
```sql linenums="1"
1677
-
select*from table(ut.run(a_tags =>'fast'));
1678
-
```
1679
-
The above call will execute both `ut_sample_test.ut_refcursors1` and `ut_sample_test.ut_test` tests, as both tests are tagged with `fast`
1619
+
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
+
See [running unit tests](running-unit-tests.md) for more information on using tags to filter test suites that are to be executed.
1680
1621
1681
1622
#### Tag naming convention
1682
1623
1683
1624
Tags must follow the below naming convention:
1684
1625
1685
1626
- tag is case sensitive
1686
-
- tag can contain special characters like `$#/\?-!` etc.
1687
-
- tag cannot be an empty string
1627
+
- tag must not contain any of the following reserved characters:
1628
+
- comma (,)
1629
+
- left or right parenthesis ((, ))
1630
+
- ampersand (&)
1631
+
- vertical bar (|)
1632
+
- exclamation point (!)
1633
+
- tag cannot be null or blank
1688
1634
- tag cannot start with a dash, e.g. `-some-stuff` is **not** a valid tag
1689
1635
- tag cannot contain spaces, e.g. `test of batch`. To create a multi-word tag use underscores or dashes, e.g. `test_of_batch`, `test-of-batch`
1690
1636
- leading and trailing spaces are ignored in tag name, e.g. `--%tags( tag1 , tag2 )` becomes `tag1` and `tag2` tag names
1691
-
1692
-
1693
-
#### Excluding tests/suites by tags
1694
-
1695
-
It is possible to exclude parts of test suites with tags.
1696
-
In order to do so, prefix the tag name to exclude with a `-` (dash) sign when invoking the test run.
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`.
1704
-
Given the above example package `ut_sample_test`, only `ut_sample_test.ut_test` will be executed.
1705
-
1637
+
- tag cannot be one of two reserved words: `none` and `any`. `none` and `any` as a tag will be treated as no tag
In addition to the path, you can filter the tests to be run by specifying tags. Tags are defined in the test / context / suite with the `--%tags`-annotation ([Read more](annotations.md#tags)).
321
321
Multiple tags are separated by comma.
322
-
The framework applies `OR` logic to all specified tags so any test / suite that matches at least one tag will be included in the test run.
322
+
323
+
324
+
### Tag Expressions
325
+
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.
327
+
328
+
Two reserved keywords, `any` and `none`, can be used when creating a tag expression to run tests.
329
+
-`any` keyword represents tests and suites with any tags
330
+
-`none` keyword represents tests and suites without tags
331
+
332
+
These keywords may be combined with other expressions just like normal tags.
333
+
334
+
!!! note
335
+
When specifying `none`, be aware that it will exclude any tests/suites/contexts contained within a tagged suite.
336
+
337
+
| Operator | Meaning |
338
+
| -------- | --------|
339
+
| ! | not |
340
+
| & | and |
341
+
|\|| or |
342
+
343
+
If you are tagging your tests across multiple dimensions, tag expressions help you to select which tests to execute. When tagging by test type (e.g., micro, integration, end-to-end) and feature (e.g., product, catalog, shipping), the following tag expressions can be useful.
344
+
345
+
346
+
| Tag Expression | Selection |
347
+
| -------- | --------|
348
+
| product | all tests for product |
349
+
| catalog \| shipping | all tests for catalog plus all tests for shipping |
350
+
| catalog & shipping | all tests that are tagged with both `catalog` and `shipping` tags |
351
+
| product & !end-to-end | all tests tagged `product`, except the tests tagged `end-to-end`|
352
+
| (micro \| integration) & (product \| shipping) | all micro or integration tests for product or shipping |
353
+
354
+
355
+
Taking the last expression above `(micro | integration) & (product | shipping)`
356
+
357
+
| --%tags |included in run |
358
+
| -------- | --------|
359
+
| micro | no |
360
+
| integration | no |
361
+
| micro | no |
362
+
| product | no |
363
+
| shipping | no |
364
+
| micro | no |
365
+
| micro, integration | no |
366
+
| product, shipping | no |
367
+
| micro, product | yes |
368
+
| micro, shipping | yes |
369
+
| integration, product | yes |
370
+
| integration, shipping | yes |
371
+
| integration, micro, shipping | yes |
372
+
| integration, micro, product | yes |
373
+
| integration, shipping ,product | yes |
374
+
| micro, shipping ,product | yes |
375
+
| integration, micro, shipping ,product | yes |
376
+
377
+
378
+
### Sample execution of test with tags.
379
+
380
+
Execution of the test with tag expressions is done using the parameter `a_tags`.
381
+
Given a test package `ut_sample_test` defined below
The above call will execute both `ut_sample_test.ut_refcursors1` and `ut_sample_test.ut_test` tests, as both tests are tagged with `fast`
435
+
436
+
### Excluding tests/suites by tags
437
+
438
+
It is possible to exclude parts of test suites with tags.
439
+
In order to do so, prefix the tag name to exclude with a `!` (exclamation) sign when invoking the test run which is equivalent of `-` (dash) in legacy notation.
The above calls 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`.
459
+
Given the above example package `ut_sample_test`, only `ut_sample_test.ut_test` will be executed.
0 commit comments