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

Skip to content

Commit e43b156

Browse files
authored
Merge pull request #524 from john-otoole/documentation-fixes-part3
Documentation fixes part3
2 parents e0e8eb6 + 801975a commit e43b156

2 files changed

Lines changed: 51 additions & 45 deletions

File tree

docs/userguide/annotations.md

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Annotations
22

33
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.
66

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.
88

9-
There are two places where annotations may appear:
9+
There are two places where annotations may appear:
1010

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.)
1313

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.
1515

1616
Procedure annotations are defined right before the procedure they reference, no empty lines are allowed.
1717

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.
1919

2020
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.
2121

@@ -48,7 +48,7 @@ create or replace package test_pkg is
4848
-- %displayname(Name of test)
4949
-- %disabled
5050
procedure disabled_test;
51-
51+
5252
-- %test(Name of test)
5353
-- %rollback(manual)
5454
procedure no_transaction_control_test;
@@ -72,15 +72,15 @@ end test_pkg;
7272
| --- | --- | --- |
7373
| `%suite(<description>)` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). |
7474
| `%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. |
7676
| `%test(<description>)` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). |
7777
| `%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. |
7878
| `%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. |
7979
| `%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. |
8080
| `%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. |
8181
| `%beforetest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. |
8282
| `%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) |
8484
| `%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. |
8585

8686
# Suitepath concept
@@ -94,10 +94,10 @@ If you want to create tests for your application it is recommended to structure
9494
* Policy tests
9595
* Claim tests
9696
* Payment tests
97-
* Payments recognition
97+
* Payments recognition
9898
* Payments set off
99-
* Payouts
100-
99+
* Payouts
100+
101101
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:
102102

103103
```sql
@@ -137,7 +137,7 @@ end test_payment_set_off;
137137
```
138138

139139
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.
141141

142142
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.
143143
```sql
@@ -158,10 +158,10 @@ A `%suitepath` can be provided in three ways:
158158
* [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`
159159
* [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.
160160

161-
# Using automatic rollbacks in tests
161+
# Using automatic rollback in tests
162162

163163
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.
165165

166166
In general, your unit tests should not use transaction control as long as the code you are testing is not using it too.
167167
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.
175175
Mixed transaction control settings will not work properly when your suites are using shared setup/cleanup with beforeall, afterall, beforeeach or aftereach annotations.
176176
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.
177177

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.
179179
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.
180180
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.
181181

182182
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.
184184

185185
# Order of execution
186186

@@ -189,23 +189,23 @@ When processing the test suite `test_pkg` defined in [Example of annotated test
189189
```
190190
create a savepoint 'beforeall'
191191
execute global_setup
192-
192+
193193
create savepoint 'beforeeach'
194194
execute test_setup
195195
execute some_test
196196
execute test_cleanup
197197
rollback to savepoint 'beforeeach'
198-
198+
199199
create savepoint 'beforeeach'
200200
execute test_setup
201201
execute setup_another_test
202202
execute another_test
203203
execute cleanup_another_test
204204
execute test_cleanup
205205
rollback to savepoint 'beforeeach'
206-
206+
207207
mark disabled_test as disabled
208-
208+
209209
execute test_setup
210210
execute no_transaction_control_test
211211
execute test_cleanup
@@ -217,23 +217,21 @@ When processing the test suite `test_pkg` defined in [Example of annotated test
217217

218218
# Annotation cache
219219

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.
222222

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.
225224

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.
230226

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.
231228
Example:
232229
```sql
233230
exec ut_runner.rebuild_annotation_cache('HR', 'PACKAGE');
234231
```
235232

236-
To purge annotations cache call:
233+
To purge the annotation cache call `ut_runner.purge_cache(a_object_owner, a_object_type)`.
234+
Example:
237235
```sql
238236
exec ut_runner.purge_cache('HR', 'PACKAGE');
239237
```

docs/userguide/install.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The script accepts three optional parameters that define:
6161
Example invocation of the script from command line:
6262
```bash
6363
cd source
64-
sqlplus sys/sys_pass@db as sysdba @@install_headless.sql
64+
sqlplus sys/sys_pass@db as sysdba @install_headless.sql
6565
```
6666

6767
Invoking script with parameters:
@@ -98,7 +98,7 @@ It is up to DBA to maintain the storage of the profiler tables.
9898
# Manual installation procedure
9999

100100
### 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:
102102

103103
- `user name` - the name of the user that will own of utPLSQL object
104104
- `password` - the password to be set for that user
@@ -121,8 +121,8 @@ cd source
121121
sqlplus admin/admins_password@database @install.sql ut3
122122
```
123123

124-
### Allowing other users to access utPLSQL framework
125-
In order to allow other users to access utPLSQL, synonyms must be created and grants need to be added.
124+
### Allowing other users to access the utPLSQL framework
125+
In order to allow other users to access utPLSQL, synonyms must be created and privileges granted.
126126
You have two options:
127127

128128
- use grants and synonyms to public, to allow all users to access the framework
@@ -135,7 +135,7 @@ Example invocation:
135135
cd source
136136
sqlplus admin/admins_password@database @create_synonyms_and_grants_for_public.sql ut3
137137
```
138-
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.
139139

140140
Example invocation:
141141
```bash
@@ -151,31 +151,39 @@ The following tools that support the SQL*Plus commands can be used to run the in
151151

152152
# Additional requirements
153153

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.
155155
This is a requirement of [DBMS_PROFILER package](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476).
156156

157157
In practice, user running tests for PLSQL code that he does not own, needs to have CREATE ANY PROCEDURE/CREATE ANY TRIGGER privileges.
158158
Running code coverage on objects that the user does not own will **not produce any coverage information** without those privileges.
159159

160160
# Uninstalling utPLSQL
161161

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.
163+
164+
Example invocation:
165+
```bash
166+
cd source
167+
sqlplus admin/admins_password@database @uninstall.sql ut3
168+
```
163169

164170
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.
166174

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.
168176

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.
171179

172180
# Version upgrade
173181

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.
175183

176184
# Working with utPLSQL v2
177185

178186
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.
180188

181189
utPLSQL v3 and utPLSQL v2 do not collide on public synonym names.

0 commit comments

Comments
 (0)