Skip to content

Commit bad6881

Browse files
committed
Updated project documentation
1 parent dabf38c commit bad6881

18 files changed

+560
-159
lines changed

docs/about/authors.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
### Version 3 Major Contributors
3-
Listed Alphabetically
3+
4+
**Listed Alphabetically**
45

56
| Name | GitHub account
67
| ------------ | --------------
@@ -9,7 +10,8 @@ Listed Alphabetically
910
| Pavel Kaplya | [Pazus](https://github.com/Pazus)
1011
| Robert Love | [rlove](https://github.com/rlove)
1112

12-
### Special thanks to prior major contributors.
13+
14+
### Special thanks to prior major contributors
1315

1416
- Steven Feuerstein - Original Author
1517
- Chris Rimmer

docs/about/license.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Version Information
22

3-
**utPLSQL version 3** is licensed under [Apache 2.0]
4-
(https://www.apache.org/licenses/LICENSE-2.0)
3+
**utPLSQL version 3** is licensed under
4+
[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
55

66
External code used in the development of this project, but is not required for use.
77

@@ -10,4 +10,6 @@ External code used in the development of this project, but is not required for u
1010
| [Travis-Oracle](https://github.com/cbandy/travis-oracle) | [ISC](https://github.com/cbandy/travis-oracle/blob/master/LICENSE) | Install Oracle for Travis Builds |
1111
| [mkDocs](http://www.mkdocs.org/) | [BSD](http://www.mkdocs.org/about/license/) | Produce HTML version of documentation |
1212

13-
**Note:** Version 1 & 2 of utPLSQL were licensed under GPL, version 3 was a complete rewrite from scratch which a allowed us to change the license to a more permissive license.
13+
**Note:**
14+
15+
Version 1 & 2 of utPLSQL were licensed under GPL, version 3 was a complete rewrite from scratch which a allowed us to change the license to be more permissive.

docs/about/project-details.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
[![twitter](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL)
77

88

9-
utPLSQL is hosted on [hosted on GitHub](https://github.com/utPLSQL/utPLSQL) and open source project.
9+
utPLSQL is open source project [hosted on GitHub](https://github.com/utPLSQL/utPLSQL).
1010

11-
Community help on this project is always appreciated, if your interested in helping please read our [guide to contributing](CONTRIBUTING.md)
11+
Contributions, help and constructive feedback is always appreciated.
12+
If you are interested in helping please read our [guide to contributing](CONTRIBUTING.md)
1213

1314

1415

docs/about/support.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# How to get support
22

3-
4-
- Feel free post questions, bugs or issues]to the [issues area of GitHub](https://github.com/utPLSQL/utPLSQL/issues).
5-
- Join developers the [utPLSQL team](http://utplsql-slack-invite.herokuapp.com) on [Slack](https://slack.com/)
3+
- Feel free post questions, bugs or issues in the [issues area of GitHub](https://github.com/utPLSQL/utPLSQL/issues).
4+
- Join developers the [utPLSQL team](http://utplsql-slack-invite.herokuapp.com) on [Slack](https://slack.com/)
-734 KB
Binary file not shown.
-868 KB
Binary file not shown.

docs/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ Check out the sections on [annotations](userguide/annotations.md) and [expectati
3939

4040

4141
# Command line
42-
The `ut_run.sql` script is a powerful thing - it can provide output from the tests on the fly.
43-
You can also use it to have coloured output from the test, and if you try to test code that was dropper, all of unit tests related to that code will fail.
42+
The `ut_run` (for linux/unix) and `ut_run.bat` (for windows) are simple yet powerful.
43+
They can provide output from the tests on the fly.
4444

45-
![colors_and_failures](images/running_from_command_line.gif)
45+
You can also use it to have coloured outputs.
4646

4747
Look into [ut_run.sql script options](userguide/ut_run-script.md) to see more.
4848

4949
# Coverage
50-
If you want to have code coverage gathered on your code , it's best to use `ut_run.sql` to execute your tests with multiple reporters and have both test execution report as well as coverage report saved to a file.
50+
If you want to have code coverage gathered on your code , it's best to use `ut_run` to execute your tests with multiple reporters and have both test execution report as well as coverage report saved to a file.
51+
5152
Check out the [coverage documentation](userguide/coverage.md) for options of coverage reporting
5253

53-
![coverage](images/running_with_coverage_line.gif)
54+
5455

5556

5657

docs/userguide/annotations.md

Lines changed: 90 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
# Annotations
22

3-
Annotations provide a way to configure tests and suites in a declarative way similar to modern OOP languages. This way th behavior of tests stored along with the test logic, versioned using VCS with the code under test. No configuration files or tables are needed. The annotation list is based on popular testing frameworks such as jUnit 5 and RSpec.
4-
The framework runner searches for all the suitable annotated packages, automatically configures suites, forms suites hierarchy, executes it and reports results in differet formats.
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.
56

6-
Annotations are case-insensitive. But it is recommended to use the lower-case standard as described in the documentation.
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.
78

8-
There are two places where annotations may appear: at the beginning of the package specification (`%suite`, `%suitepath` etc) and right before a procedure (`%test`, `%beforeall`, `%beforeeach` etc). Package level annotations are separated by at least one empty line from the following procedure annotations. Procedure annotetions are defined right before the procedure they reference, no empty lines allowed.
9+
There are two places where annotations may appear:
910

10-
If a package conatins `%suite` annotation in its specification part it is treated as a test package and processed by the framework.
11+
- at the beginning of the package specification (`%suite`, `%suitepath` etc)
12+
- right before a procedure (`%test`, `%beforeall`, `%beforeeach` etc).
1113

12-
Some annotations accept parameters like `%suite`, `%test` `%displayname`, then the values are provided without any quatation marks, parameters are separated by commas.
14+
Package level annotations need to be separated by at least one empty line from the underlying procedure annotations.
1315

14-
# Example of annotated test package
16+
Procedure annotations are defined right before the procedure they reference, no empty lines are allowed.
17+
18+
If a package specification contains `%suite` annotation, it is treated as a test package and processed by the framework.
19+
20+
Some annotations accept parameters like `%suite`, `%test` `%displayname`. The parameters for annotations need to be placed in brackets. Values for parameters should be provided without any quotation marks.
21+
22+
# <a name="example"></a>Example of annotated test package
1523

1624
```sql
1725
create or replace package test_pkg is
@@ -20,73 +28,63 @@ create or replace package test_pkg is
2028
-- %suitepath(all.globaltests)
2129

2230
-- %beforeall
23-
procedure globalsetup;
31+
procedure global_setup;
2432

2533
-- %afterall
26-
procedure global_teardown;
34+
procedure global_cleanup;
2735

2836
/* Such comments are allowed */
2937

3038
-- %test
31-
-- %displayname(Name of test1)
32-
procedure test1;
39+
-- %displayname(Name of a test)
40+
procedure some_test;
3341

34-
-- %test(Name of test2)
35-
-- %beforetest(setup_test1)
36-
-- %aftertest(teardown_test1)
37-
procedure test2;
42+
-- %test(Name of another test)
43+
-- %beforetest(setup_another_test)
44+
-- %aftertest(cleanup_another_test)
45+
procedure another_test;
3846

3947
-- %test
40-
-- %displayname(Name of test3)
48+
-- %displayname(Name of test)
4149
-- %disabled
42-
procedure test3;
50+
procedure disabled_test;
4351

44-
-- %test(Name of test4)
52+
-- %test(Name of test)
4553
-- %rollback(manual)
46-
procedure test4;
54+
procedure no_transaction_control_test;
4755

48-
procedure setup_test1;
56+
procedure setup_another_test;
4957

50-
procedure teardown_test1;
58+
procedure cleanup_another_test;
5159

5260
-- %beforeeach
53-
procedure setup;
61+
procedure test_setup;
5462

5563
-- %aftereach
56-
procedure teardown;
64+
procedure test_cleanup;
5765

5866
end test_pkg;
5967
```
6068

61-
# Annotations description
69+
# Supported annotations
6270

6371
| Annotation |Level| Description |
6472
| --- | --- | --- |
65-
| `%suite(<description>)` | Package | Marks package to be a suite of tests This way all testing packages might be found in a schema. Optional schema discription can by provided, similar to `%displayname` annotation. |
73+
| `%suite(<description>)` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). |
6674
| `%suitepath(<path>)` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. |
67-
| `%displayname(<description>)` | Package/procedure | Human-familiar description of the suite/test. Syntax is based on jUnit annotation: `%displayname(Name of the suite/test)` |
68-
| `%test(<description>)` | Procedure | Denotes that a method is a test method. Optional test description can by provided, similar to `%displayname` annotation. |
69-
| `%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the current suite. |
70-
| `%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the current suite. |
71-
| `%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` method in the current suite. |
72-
| `%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` method in the current suite. |
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. |
76+
| `%test(<description>)` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can by provided (see `displayname`). |
77+
| `%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. |
78+
| `%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. |
79+
| `%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. |
80+
| `%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. |
7381
| `%beforetest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. |
7482
| `%aftertest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. |
75-
| `%rollback(<type>)` | Package/procedure | Configure transaction control behaviour (type). 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) |
76-
| `%disabled` | Package/procedure | Used to disable a suite or a test |
77-
78-
# Using automatic rollbacks in tests
79-
By default, every test is isolated from other tests using savepoint.
80-
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 commands (commit/rollback).
81-
In general, your unit tests should not use transaction control as long as the core you are testing is not using it too.
82-
Keeping the transactions uncommitted allows your changes to be isolated and the execution of tests is not impacting others that might be using a shared (integration) development database.
83-
84-
If however you're in situation, where the code you are testing, is using transaction control (like ETL code is usually doing), then your tests should not use the default rollback(auto)
85-
You should make sure that thr entire suitepath all the way to the root is using manual transaction control in that case.
86-
87-
In some cases it is needed to perform DDL in setup/teardown. It is recommended to move such DDL statements to a procedure with pragma autonomous_transaction to eliminate implicit commit of the main session.
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+
| `%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. |
8885

8986
# Suitepath concept
87+
9088
It is very likely that the application for which you are going to introduce tests consists of many different packages or procedures/functions. Usually procedures can be logically grouped inside a package, there also might be several logical groups of procedure in a single package or even packages themselves might relate to a common module.
9189

9290
Lets say you have a complex insurance application the operates with policies, claims and payments. The payment module contains several packages for payment recognition, charging, planning etc. The payment recognition module among others contains a complex `recognize_payment` procedure that associates received money to the policies.
@@ -160,3 +158,51 @@ A `%suitepath` can be provided in tree ways:
160158
* [schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests in all suites from suite1[.suite2][.suite3]...[.procedure] path. If schema is not provided, then current schema is used. Example: `:all.rooms_tests`.
161159
* [schema.]package[.procedure] - execute all tests in the test package provided. The whole hierarchy of suites in the schema is build before, all before/after hooks of partn suites for th 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.
162160

161+
# Using automatic rollbacks in tests
162+
163+
By default, every test is isolated using savepoint.
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.
165+
In general, your unit tests should not use transaction control as long as the code you are testing is not using it too.
166+
Keeping the transactions uncommitted allows your changes to be isolated and the execution of tests is not impacting others that might be using a shared development database.
167+
168+
If you are in situation, where the code you are testing, is using transaction control (common case with ETL code), then your tests probably should not use the default automatic transaction control.
169+
In that case use the annotation `-- %rollback(manual)` on the suite level to disable automatic transaction control for entire suite.
170+
If you are using nested suites, you need to make sure that thr entire suite all the way to the root is using manual transaction control.
171+
172+
In some cases it is needed to perform DDL as part of setup or cleanup for the tests.
173+
It is recommended to move such DDL statements to a procedure with `pragma autonomous_transaction` to eliminate implicit commit of the main session.
174+
Doing so, allows your test to use automatic transaction control of the framework and release you from the burden of manual cleanup of data that was created or modified by test execution.
175+
176+
177+
# Order of execution
178+
179+
When processing the test suite `test_pkg` defined in [Example of annotated test package](#example), the execution will be done in the following order.
180+
181+
```
182+
create a savepoint 'beforeall'
183+
execute global_setup
184+
185+
create savepoint 'beforeeach'
186+
execute test_setup
187+
execute some_test
188+
execute test_cleanup
189+
rollback to savepoint 'beforeeach'
190+
191+
create savepoint 'beforeeach'
192+
execute test_setup
193+
execute setup_anotrher_test
194+
execute another_test
195+
execute cleanup_another_test
196+
execute test_cleanup
197+
rollback to savepoint 'beforeeach'
198+
199+
mark disabled_test as disabled
200+
201+
execute test_setup
202+
execute no_transaction_control_test
203+
execute test_cleanup
204+
205+
execute global_cleanup
206+
rollback to savepoint 'beforeall'
207+
208+
```

0 commit comments

Comments
 (0)