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
+30-32Lines changed: 30 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
# Annotations
2
2
3
3
Annotations are used to configure tests and suites in a declarative way similar to modern OOP languages. This way, test configuration is stored along with the test logic inside the test package.
4
-
No configuration files or tables are needed. The annotations names are based on popular testing frameworks such as jUnit.
5
-
The framework runner searches for all the suitable annotated packages, automatically configures suites, forms suites hierarchy, executes it and reports results in specified formats.
4
+
No configuration files or tables are needed. The annotation names are based on popular testing frameworks such as jUnit.
5
+
The framework runner searches for all the suitable annotated packages, automatically configures suites, forms the suite hierarchy, executes it and reports results in specified formats.
6
6
7
-
Annotations are interpreted only in package specification and are case-insensitive. It is recommended however, to use the lower-case annotations as described in documentation.
7
+
Annotations are interpreted only in the package specification and are case-insensitive. It is recommended however, to use lower-case annotations as described in this documentation.
8
8
9
-
There are two places where annotations may appear:
9
+
There are two places where annotations may appear:
10
10
11
-
- at the beginning of the package specification (`%suite`, `%suitepath` etc)
12
-
- right before a procedure (`%test`, `%beforeall`, `%beforeeach` etc).
11
+
- at the beginning of the package specification (`%suite`, `%suitepath` etc.)
12
+
- right before a procedure (`%test`, `%beforeall`, `%beforeeach` etc.)
13
13
14
-
Package level annotations need to be separated by at least one empty line from the underlying procedure annotations.
14
+
Package level annotations need to be separated by at least one empty line from the underlying procedure annotations.
15
15
16
16
Procedure annotations are defined right before the procedure they reference, no empty lines are allowed.
17
17
18
-
If a package specification contains `%suite` annotation, it is treated as a test package and processed by the framework.
18
+
If a package specification contains the `%suite` annotation, it is treated as a test package and is processed by the framework.
19
19
20
20
Some annotations accept parameters like `%suite`, `%test` and `%displayname`. The parameters for annotations need to be placed in brackets. Values for parameters should be provided without any quotation marks.
21
21
@@ -48,7 +48,7 @@ create or replace package test_pkg is
48
48
-- %displayname(Name of test)
49
49
-- %disabled
50
50
procedure disabled_test;
51
-
51
+
52
52
-- %test(Name of test)
53
53
-- %rollback(manual)
54
54
procedure no_transaction_control_test;
@@ -72,15 +72,15 @@ end test_pkg;
72
72
| --- | --- | --- |
73
73
|`%suite(<description>)`| Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). |
74
74
|`%suitepath(<path>)`| Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. |
75
-
|`%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 `<descriotion>` in `test` and `suite` annotations. If description is provided using both `suite`/`test` and `displayname`, then the one defined as last takes precedence. |
75
+
|`%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. |
76
76
|`%test(<description>)`| Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). |
77
77
|`%beforeall`| Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. |
78
78
|`%afterall`| Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. |
79
79
|`%beforeeach`| Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. |
80
80
|`%aftereach`| Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. |
81
81
|`%beforetest(<procedure_name>)`| Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. |
82
82
|`%aftertest(<procedure_name>)`| Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. |
83
-
|`%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) |
83
+
|`%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) |
84
84
|`%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. |
85
85
86
86
# Suitepath concept
@@ -94,10 +94,10 @@ If you want to create tests for your application it is recommended to structure
94
94
* Policy tests
95
95
* Claim tests
96
96
* Payment tests
97
-
* Payments recognition
97
+
* Payments recognition
98
98
* Payments set off
99
-
* Payouts
100
-
99
+
* Payouts
100
+
101
101
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:
102
102
103
103
```sql
@@ -137,7 +137,7 @@ end test_payment_set_off;
137
137
```
138
138
139
139
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.
140
-
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.
140
+
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.
141
141
142
142
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.
143
143
```sql
@@ -158,10 +158,10 @@ A `%suitepath` can be provided in three ways:
158
158
*[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`
159
159
*[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.
160
160
161
-
# Using automatic rollbacks in tests
161
+
# Using automatic rollback in tests
162
162
163
163
By default, changes performed by every setup, cleanup and test procedure are isolated by savepoints.
164
-
This solution is suitable for use-cases where the code that is getting tested as well as the unit tests themselves do not use transaction control (commit/rollback) or DDL commands.
164
+
This solution is suitable for use-cases where the code that is being tested as well as the unit tests themselves do not use transaction control (commit/rollback) or DDL commands.
165
165
166
166
In general, your unit tests should not use transaction control as long as the code you are testing is not using it too.
167
167
Keeping the transactions uncommitted allows your changes to be isolated and the execution of tests does not impact others who might be using a shared development database.
@@ -175,12 +175,12 @@ It is strongly recommended not to have mixed transaction control in a suite.
175
175
Mixed transaction control settings will not work properly when your suites are using shared setup/cleanup with beforeall, afterall, beforeeach or aftereach annotations.
176
176
Your suite will most likely fail with error or warning on execution. Some of the automatic rollbacks will probably fail to execute depending on the configuration you have.
177
177
178
-
In some cases it is necessary to perform DDL as part of setup or cleanup for the tests.
178
+
In some cases it is necessary to perform DDL as part of setup or cleanup for the tests.
179
179
It is recommended to move such DDL statements to a procedure with `pragma autonomous_transaction` to eliminate implicit commits in the main session that is executing all your tests.
180
180
Doing so allows your tests to use the framework's automatic transaction control and releases you from the burden of manual cleanup of data that was created or modified by test execution.
181
181
182
182
When you are testing code that performs explicit or implicit commits, you may set the test procedure to run as an autonomous transaction with `pragma autonomous_transaction`.
183
-
Keep in mind that when your tests runs in autonomous transaction it will not see the data prepared in setup procedure unless the setup procedure committed the changes.
183
+
Keep in mind that when your test runs as autonomous transaction it will not see the data prepared in a setup procedure unless the setup procedure committed the changes.
184
184
185
185
# Order of execution
186
186
@@ -189,23 +189,23 @@ When processing the test suite `test_pkg` defined in [Example of annotated test
189
189
```
190
190
create a savepoint 'beforeall'
191
191
execute global_setup
192
-
192
+
193
193
create savepoint 'beforeeach'
194
194
execute test_setup
195
195
execute some_test
196
196
execute test_cleanup
197
197
rollback to savepoint 'beforeeach'
198
-
198
+
199
199
create savepoint 'beforeeach'
200
200
execute test_setup
201
201
execute setup_another_test
202
202
execute another_test
203
203
execute cleanup_another_test
204
204
execute test_cleanup
205
205
rollback to savepoint 'beforeeach'
206
-
206
+
207
207
mark disabled_test as disabled
208
-
208
+
209
209
execute test_setup
210
210
execute no_transaction_control_test
211
211
execute test_cleanup
@@ -217,23 +217,21 @@ When processing the test suite `test_pkg` defined in [Example of annotated test
217
217
218
218
# Annotation cache
219
219
220
-
utPLSQL needs to scan sources of package specifications to identify and parse annotations.
221
-
To improve framework startup time, specially when dealing with database users owning large amount of packages the framework has build-in persistent cache for annotations.
220
+
utPLSQL needs to scan the source of package specifications to identify and parse annotations.
221
+
To improve framework startup time, especially when dealing with database users owning large amounts of packages, the framework has a built-in persistent cache for annotations.
222
222
223
-
Cache is checked for staleness and refreshed automatically on every run.
224
-
The initial startup of utPLSQL for a schema will take longer than consecutive executions.
223
+
The annotation cache is checked for staleness and refreshed automatically on every run. The initial startup of utPLSQL for a schema will take longer than consecutive executions.
225
224
226
-
If you're in situation, where your database is controlled via CI/CD server and gets refreshed/wiped before each run of your tests,
227
-
consider building upfront and creating the snapshot of our database after the cache was refreshed.
228
-
229
-
To build annotation cache without actually invoking any tests, call `ut_runner.rebuild_annotation_cache(a_object_owner, a_object_type)` sql block for every unit test owner that you want to have annotations cache prebuilt.
225
+
If you are in a situation where your database is controlled via CI/CD server and is refreshed/wiped before each run of your tests, consider building the annotation cache upfront and taking a snapshot of the database after the cache has been refreshed.
230
226
227
+
To build the annotation cache without actually invoking any tests, call `ut_runner.rebuild_annotation_cache(a_object_owner, a_object_type)` for every unit test owner for which you want to have the annotation cache prebuilt.
Copy file name to clipboardExpand all lines: docs/userguide/install.md
+21-13Lines changed: 21 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ The script accepts three optional parameters that define:
61
61
Example invocation of the script from command line:
62
62
```bash
63
63
cdsource
64
-
sqlplus sys/sys_pass@db as sysdba @@install_headless.sql
64
+
sqlplus sys/sys_pass@db as sysdba @install_headless.sql
65
65
```
66
66
67
67
Invoking script with parameters:
@@ -98,7 +98,7 @@ It is up to DBA to maintain the storage of the profiler tables.
98
98
# Manual installation procedure
99
99
100
100
### Creating schema for utPLSQL
101
-
To create the utPLSQL schema and grant all the needed privileges execute script `create_utplsql_owner.sql` from the `source` directory with parameters:
101
+
To create the utPLSQL schema and grant all the required privileges execute script `create_utplsql_owner.sql` from the `source` directory with parameters:
102
102
103
103
-`user name` - the name of the user that will own of utPLSQL object
104
104
-`password` - the password to be set for that user
To grant utPLSQL to individual user execute script `source/create_synonyms_and_grants_for_user.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for.
138
+
To grant utPLSQL to an individual user, execute script `source/create_synonyms_and_grants_for_user.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for.
139
139
140
140
Example invocation:
141
141
```bash
@@ -151,31 +151,39 @@ The following tools that support the SQL*Plus commands can be used to run the in
151
151
152
152
# Additional requirements
153
153
154
-
In order to use Code Coverage functionality of utPLSQL, users executing the tests must have the CREATE privilege on the PLSQL code that the coverage is gathered on.
154
+
In order to use the Code Coverage functionality of utPLSQL, users executing the tests must have the CREATE privilege on the PLSQL code that the coverage is gathered on.
155
155
This is a requirement of [DBMS_PROFILER package](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476).
156
156
157
157
In practice, user running tests for PLSQL code that he does not own, needs to have CREATE ANY PROCEDURE/CREATE ANY TRIGGER privileges.
158
158
Running code coverage on objects that the user does not own will **not produce any coverage information** without those privileges.
159
159
160
160
# Uninstalling utPLSQL
161
161
162
-
To uninstall run `/source/uninstall.sql` and provide `schema_name` where utPLSQL is installed.
162
+
To uninstall run `uninstall.sql` and provide `schema_name` where utPLSQL is installed.
The uninstall script will remove all the objects installed by the install script.
165
-
Additionally, all the public and private synonyms pointing to the objects in utPLSQL schema will be removed.
171
+
Additionally, all the public and private synonyms pointing to the objects in the utPLSQL schema will be removed.
172
+
173
+
If you have extended any utPLSQL types such as a custom reporter, these will need to be dropped before the uninstall, otherwise the uninstall script might fail.
166
174
167
-
If you have you have extended any utPLSQL types such as a custom reporter, these will need to be dropped before the uninstall, otherwise the uninstall script might fail.
175
+
The uninstall script does not drop the schema.
168
176
169
-
In order for the uninstall to be successful, you need to use the uninstall script, that was provided whit the exact version that was installed on your database.
170
-
The uninstall script provided with version 3.0.1 will probably not work, if you want to remove version 3.0.0 from your database.
177
+
In order for the uninstall to be successful, you need to use the uninstall script that was provided with the exact utPLSQL version installed on your database.
178
+
i.e. the uninstall script provided with version 3.0.1 will probably not work if you want to remove version 3.0.0 from your database.
171
179
172
180
# Version upgrade
173
181
174
-
Currently, the only way to upgrade version of utPLSQL v3.0.0 and above is to remove the previous version and install new version
182
+
Currently, the only way to upgrade version of utPLSQL v3.0.0 and above is to remove the previous version and install the new version.
175
183
176
184
# Working with utPLSQL v2
177
185
178
186
If you are using utPLSQL v2, you can still install utPLSQL v3.
179
-
The only requirement is that utPLSQL v3 needs to be installed in different schema than utPLSQL v2.
187
+
The only requirement is that utPLSQL v3 needs to be installed in a different schema than utPLSQL v2.
180
188
181
189
utPLSQL v3 and utPLSQL v2 do not collide on public synonym names.
0 commit comments