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
@@ -21,9 +21,9 @@ We strongly recommend putting package level annotations at the very top of packa
21
21
| --- | --- | --- |
22
22
|`--%suite(<description>)`| Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). |
23
23
|`--%suitepath(<path>)`| Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. |
24
-
|`--%displayname(<description>)`| Package/procedure | Human-readable and meaningful description of a context/suite/test. Provides description to a `context` when used within `context`. When used with `test` or `suite` annotation, overrides the `<description>` provided with `suite`/`test`. |
24
+
|`--%displayname(<description>)`| Package/procedure | Human-readable and meaningful description of a context/suite/test. Overrides the `<description>` provided with `suite`/`test`/`context` annotation. This annotation is redundant and might be removed in future releases. |
25
25
|`--%test(<description>)`| Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). |
26
-
|`--%throws(<exception>[,...])`| Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric contant names, exception constant names, predefined Oracle exception names. |
26
+
|`--%throws(<exception>[,...])`| Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric constant names, exception constant names, predefined Oracle exception names. |
27
27
|`--%beforeall`| Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. |
28
28
|`--%beforeall([[<owner>.]<package>.]<procedure>[,...])`| Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. |
29
29
|`--%afterall`| Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. |
@@ -36,7 +36,8 @@ We strongly recommend putting package level annotations at the very top of packa
36
36
|`--%aftertest([[<owner>.]<package>.]<procedure>[,...])`| Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. |
37
37
|`--%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) |
38
38
|`--%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. |
39
-
|`--%context(<name>)`| Package | Denotes start of a named context (sub-suite) in a suite package |
39
+
|`--%context(<description>)`| Package | Denotes start of a named context (sub-suite) in a suite package an optional description for context can be provided. |
40
+
|`--%name(<name>)`| Package | Denotes name for a context. Must be placed after the context annotation and before start of nested context. |
40
41
|`--%endcontext`| Package | Denotes end of a nested context (sub-suite) in a suite package |
41
42
|`--%tags`| Package/procedure | Used to label a test or a suite for purpose of identification |
42
43
@@ -1008,14 +1009,15 @@ Contexts allow for creating sub-suites within a suite package and they allow for
1008
1009
In essence, context behaves like a suite within a suite.
1009
1010
1010
1011
Context have following characteristics:
1011
-
- context starts with the `--%context` annotation and ends with `--%endcontext`
1012
-
- can have a name provided as parameter for example `--%context(remove_rooms_by_name)`. This is different than with `suite` and `test` annotations, where name is taken from test `package/procedure`
1013
-
- when no name is provided for context, the context is named `context_N` where `N` is the number of the context in suite or parent context
1014
-
- context name must be unique within it's parent (suite or parent context)
1012
+
- context starts with the `--%context` annotation and ends with `--%endcontext`. Everything placed between those two annotations belongs to that context
1013
+
- can have a description provided as parameter for example `--%context(Some interesting stuff)`.
1014
+
- can have a name provided with `--%name` annotation. This is different than with `suite` and `test` annotations, where name is taken from `package/procedure` name.
1015
+
- contexts can be nested, you can place a context inside another context
1016
+
- when no name is provided for context, the context is named `context_N` where `N` is the number of the context in suite or parent context.
1017
+
- context name must be unique within it's parent (suite / parent context)
1015
1018
- if context name is not unique within it's parent, context and it's entire content is excluded from execution
1016
1019
- context name should not contain spaces or special characters
1017
1020
- context name cannot contain a `.` (full stop/period) character
1018
-
- contexts can be nested, so a context can be nested within another context
1019
1021
- suite/context can have multiple nested sibling contexts in it
1020
1022
- contexts can have their own `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures
1021
1023
-`--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at ancestor level, propagate to context
@@ -1231,8 +1233,7 @@ Example of nested contexts test suite specification.
1231
1233
create or replace package queue_spec as
1232
1234
--%suite(Queue specification)
1233
1235
1234
-
--%context(a_new_queue)
1235
-
--%displayname(A new queue)
1236
+
--%context(A new queue)
1236
1237
1237
1238
--%test(Is empty)
1238
1239
procedure is_empty;
@@ -1241,8 +1242,7 @@ create or replace package queue_spec as
1241
1242
--%test(Cannot be created with non positive bounding capacity)
1242
1243
procedure non_positive_bounding_cap;
1243
1244
--%endcontext
1244
-
--%context(an_empty_queue)
1245
-
--%displayname(An empty queue)
1245
+
--%context(An empty queue)
1246
1246
1247
1247
--%test(Dequeues an empty value)
1248
1248
procedure deq_empty_value;
@@ -1251,19 +1251,16 @@ create or replace package queue_spec as
1251
1251
--%test(Becomes non empty when non null value enqueued)
1252
1252
procedure non_empty_after_enq;
1253
1253
--%endcontext
1254
-
--%context(a_non_empty_queue)
1255
-
--%displayname(A non empty queue)
1254
+
--%context(A non empty queue)
1256
1255
1257
-
--%context(that_is_not_full)
1258
-
--%displayname(that is not full)
1256
+
--%context(that is not full)
1259
1257
1260
1258
--%test(Becomes longer when non null value enqueued)
1261
1259
procedure grow_on_enq_non_null;
1262
1260
--%test(Becomes full when enqueued up to capacity)
1263
1261
procedure full_on_enq_to_cap;
1264
1262
--%endcontext
1265
-
--%context(that_is_full)
1266
-
--%displayname(That is full)
1263
+
--%context(that is full)
1267
1264
1268
1265
--%test(Ignores further enqueued values)
1269
1266
procedure full_ignore_enq;
@@ -1312,6 +1309,122 @@ Finished in .088573 seconds
1312
1309
1313
1310
Suite nesting allows for organizing tests into human-readable specification of behavior.
1314
1311
1312
+
### Name
1313
+
The `--%name` annotation is currently only used only for naming a context.
1314
+
If a context doesn't have explicit name specified, then the name is given automatically by framework.
1315
+
1316
+
The automatic name will be `context_#n` where `n` is a context number within a suite/parent context.
1317
+
1318
+
The `--%name` can be useful when you would like to run only a specific context or its items by `suitepath`.
1319
+
1320
+
Consider the below example.
1321
+
1322
+
```sql
1323
+
create or replace package queue_spec as
1324
+
--%suite(Queue specification)
1325
+
1326
+
--%context(A new queue)
1327
+
1328
+
--%test(Cannot be created with non positive bounding capacity)
1329
+
procedure non_positive_bounding_cap;
1330
+
--%endcontext
1331
+
--%context(An empty queue)
1332
+
1333
+
--%test(Becomes non empty when non null value enqueued)
1334
+
procedure non_empty_after_enq;
1335
+
--%endcontext
1336
+
--%context(A non empty queue)
1337
+
1338
+
--%context(that is not full)
1339
+
1340
+
--%test(Becomes full when enqueued up to capacity)
1341
+
procedure full_on_enq_to_cap;
1342
+
--%endcontext
1343
+
--%context(that is full)
1344
+
1345
+
--%test(Becomes non full when dequeued)
1346
+
procedure non_full_on_deq;
1347
+
--%endcontext
1348
+
1349
+
--%endcontext
1350
+
end;
1351
+
```
1352
+
1353
+
In the above code, suitepaths, context names and context descriptions will be as follows.
1354
+
1355
+
| suitepath | description | name |
1356
+
|-----------|------------|------|
1357
+
| queue_spec | Queue specification | queue_spec |
1358
+
| queue_spec.context_#1 | A new queue | context_#1 |
1359
+
| queue_spec.context_#2 | An empty queue | context_#2 |
1360
+
| queue_spec.context_#3 | A non empty queue | context_#3 |
1361
+
| queue_spec.context_#3.context_#1 | that is not full | context_#1 |
1362
+
| queue_spec.context_#3.context_#2 | that is full | context_#2 |
1363
+
1364
+
In order to run only the tests for the context `A non empty queue that is not full` you will need to call utPLSQL as below:
1365
+
```sql
1366
+
exec ut.run(':queue_spec.context_#3.context_#1');
1367
+
```
1368
+
1369
+
You can use `--%name` annotation to explicitly name contexts on suitepath.
1370
+
```sql
1371
+
create or replace package queue_spec as
1372
+
--%suite(Queue specification)
1373
+
1374
+
--%context(A new queue)
1375
+
--%name(a_new_queue)
1376
+
1377
+
--%test(Cannot be created with non positive bounding capacity)
1378
+
procedure non_positive_bounding_cap;
1379
+
--%endcontext
1380
+
--%context(An empty queue)
1381
+
--%name(an_empty_queue)
1382
+
1383
+
--%test(Becomes non empty when non null value enqueued)
1384
+
procedure non_empty_after_enq;
1385
+
--%endcontext
1386
+
--%context(A non empty queue)
1387
+
--%name(a_non_empty_queue)
1388
+
1389
+
--%context(that is not full)
1390
+
--%name(that_is_not_full)
1391
+
1392
+
--%test(Becomes full when enqueued up to capacity)
1393
+
procedure full_on_enq_to_cap;
1394
+
--%endcontext
1395
+
--%context(that is full)
1396
+
--%name(that_is_full)
1397
+
1398
+
--%test(Becomes non full when dequeued)
1399
+
procedure non_full_on_deq;
1400
+
--%endcontext
1401
+
1402
+
--%endcontext
1403
+
end;
1404
+
```
1405
+
1406
+
In the above code, suitepaths, context names and context descriptions will be as follows.
1407
+
1408
+
| suitepath | description | name |
1409
+
|-----------|------------|------|
1410
+
| queue_spec | Queue specification | queue_spec |
1411
+
| queue_spec.a_new_queue | A new queue | a_new_queue |
1412
+
| queue_spec.an_empty_queue | An empty queue | an_empty_queue |
1413
+
| queue_spec.a_non_empty_queue | A non empty queue | a_non_empty_queue |
1414
+
| queue_spec.a_non_empty_queue.that_is_not_full | that is not full | that_is_not_full |
1415
+
| queue_spec.a_non_empty_queue.that_is_full | that is full | that_is_full |
1416
+
1417
+
1418
+
The `--%name` annotation is only relevant for:
1419
+
- running subsets of tests by given context suitepath
1420
+
- some of test reports, like `ut_junit_reporter` that use suitepath or test-suite element names (not descriptions) for reporting
1421
+
1422
+
#### Name naming convention
1423
+
1424
+
The value of `--%name` annotation must follow the following naming rules:
1425
+
- cannot contain spaces
1426
+
- cannot contain a `.` (full stop/dot)
1427
+
- is case-insensitive
1315
1428
1316
1429
### Tags
1317
1430
@@ -1440,8 +1553,9 @@ If you want to create tests for your application it is recommended to structure
1440
1553
* Payments recognition
1441
1554
* Payments set off
1442
1555
1443
-
The `%suitepath` annotation is used for such grouping. Even though test packages are defined in a flat structure the `%suitepath` is used by the framework to form them into a hierarchical structure. Your payments recognition test package might look like:
1556
+
The `--%suitepath` annotation is used for such grouping. Even though test packages are defined in a flat structure the `--%suitepath` is used by the framework to form them into a hierarchical structure.
1444
1557
1558
+
Your payments recognition test package might look like:
1445
1559
```sql
1446
1560
create or replace package test_payment_recognition as
1447
1561
@@ -1476,8 +1590,8 @@ create or replace package test_payment_set_off as
1476
1590
end test_payment_set_off;
1477
1591
```
1478
1592
1479
-
When you execute tests for your application, the framework constructs a test suite for each test package. Then it combines suites into grouping suites by the `%suitepath` annotation value so that the fully qualified path to the `recognize_by_num` procedure is `USER:payments.test_payment_recognition.test_recognize_by_num`. If any of its expectations fails then the test is marked as failed, also the `test_payment_recognition` suite, the parent suite `payments` and the whole run is marked as failed.
1480
-
The test report indicates which expectation has failed on the payments module. The payments recognition submodule is causing the failure as `recognize_by_num` has not met the expectations of the test. Grouping tests into modules and submodules using the `%suitepath` annotation allows you to logically organize your project's flat structure of packages into functional groups.
1593
+
When you execute tests for your application, the framework constructs a test suite for each test package. Then it combines suites into grouping suites by the `--%suitepath` annotation value so that the fully qualified path to the `recognize_by_num` procedure is `USER:payments.test_payment_recognition.test_recognize_by_num`. If any of its expectations fails then the test is marked as failed, also the `test_payment_recognition` suite, the parent suite `payments` and the whole run is marked as failed.
1594
+
The test report indicates which expectation has failed on the payments module. The payments recognition submodule is causing the failure as `recognize_by_num` has not met the expectations of the test. Grouping tests into modules and submodules using the `--%suitepath` annotation allows you to logically organize your project's flat structure of packages into functional groups.
1481
1595
1482
1596
An additional advantage of such grouping is the fact that every element level of the grouping can be an actual unit test package containing a common module level setup for all of the submodules. So in addition to the packages mentioned above you could have the following package.
1483
1597
```sql
@@ -1493,9 +1607,10 @@ create or replace package payments as
1493
1607
1494
1608
end payments;
1495
1609
```
1496
-
A `%suitepath` can be provided in three ways:
1610
+
1611
+
When executing tests, `path` for executing tests can be provided in three ways:
1497
1612
* schema - execute all tests in the schema
1498
-
*[schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests in all suites from suite1[.suite2][.suite3]...[.procedure] path. If schema is not provided, then the current schema is used. Example: `:all.rooms_tests`
1613
+
*[schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests by `suitepath`in all suites on path suite1[.suite2][.suite3]...[.procedure]. If schema is not provided, then the current schema is used. Example: `:all.rooms_tests`
1499
1614
*[schema.]package[.procedure] - execute all tests in the specified test package. The whole hierarchy of suites in the schema is built before all before/after hooks or part suites for the provided suite package are executed as well. Example: `tests.test_contact.test_last_name_validator` or simply `test_contact.test_last_name_validator` if `tests` is the current schema.
0 commit comments