Skip to content

Commit 409a70e

Browse files
authored
Merge pull request #1015 from utPLSQL/feature/update_annotation_doc
Updated description of annotation types
2 parents b07d0e9 + 06a6881 commit 409a70e

1 file changed

Lines changed: 86 additions & 2 deletions

File tree

docs/userguide/annotations.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,95 @@ The framework runner searches for all the suitable annotated packages, automatic
99
Annotations are interpreted only in the package specification and are case-insensitive. We strongly recommend using lower-case annotations as described in this documentation.
1010

1111
There are two distinct types of annotations, identified by their location in package:
12-
- Procedure level annotations - placed directly before a procedure (`--%test`, `--%beforeall`, `--%beforeeach` etc.).
13-
- Package level annotations - placed at any place in package except directly before procedure (`--%suite`, `--%suitepath` etc.).
1412

13+
### Procedure level annotations
14+
15+
Annotation placed directly before a procedure (`--%test`, `--%beforeall`, `--%beforeeach` etc.).
16+
There **can not** be any empty lines or comments between annotation line and procedure line.
17+
There can be many annotations for a procedure.
18+
19+
Valid procedure annotations example:
20+
```sql
21+
package test_package is
22+
--%suite
23+
24+
25+
--%test()
26+
--%disabled
27+
procedure my_first_procedure;
28+
29+
$if dbms_db_version.version >= 12 $then --This is ok - annotation before procedure
30+
--%test()
31+
procedure my_first_procedure;
32+
$end
33+
34+
--A comment goes before annotations
35+
--%test()
36+
procedure my_first_procedure;
37+
end;
38+
```
39+
40+
Invalid procedure annotations examples:
41+
```sql
42+
package test_package is
43+
--%suite
44+
45+
--%test() --This is wrong as there is an empty line between procedure and annotation
46+
47+
procedure my_first_procedure;
48+
49+
--%test()
50+
--This is wrong as there is a comment line between procedure and annotation
51+
procedure proc1;
52+
53+
--%test() --This is wrong as there is a compiler directive between procedure and annotation
54+
$if dbms_db_version.version >= 12 $then
55+
procedure proc_12;
56+
$end
57+
58+
--%test()
59+
-- procedure another_proc;
60+
/* The above is wrong as the procedure is commented out
61+
and annotation is not procedure annotation anymore */
62+
63+
end;
64+
```
65+
66+
### Package level annotations
67+
68+
Those annotations placed at any place in package except directly before procedure (`--%suite`, `--%suitepath` etc.).
1569
We strongly recommend putting package level annotations at the very top of package except for the `--%context` annotations (described below)
1670

71+
Valid package annotations example:
72+
```sql
73+
package test_package is
74+
75+
--%suite
76+
77+
--%suitepath(org.utplsql.example)
78+
79+
--%beforeall(some_package.some_procedure)
80+
81+
--%context
82+
83+
--%test()
84+
procedure my_first_procedure;
85+
--%endcontext
86+
end;
87+
```
88+
89+
Invalid package annotations examples:
90+
```sql
91+
package test_package is
92+
--%suite --This is wrong as suite annotation is not a procedure annotation
93+
procedure irrelevant;
94+
95+
--%context --This is wrong as there is no empty line between package level annotation and procedure level annotation
96+
--%test()
97+
procedure my_first_procedure;
98+
99+
end;
100+
```
17101

18102
## Supported annotations
19103

0 commit comments

Comments
 (0)