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
When multiple `--%suite` annotations are specified in package, the first annotation will be used and a warning message will appear indicating duplicate annotation.
When multiple `--%test` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation.
@@ -532,7 +532,7 @@ The procedure annotated as `--%beforeeach` is getting executed before each test
532
532
That means that the procedure will be executed as many times as there are test in suite package.
533
533
534
534
If a test is marked as disabled the `--%beforeeach` procedure is not invoked for that test.
535
-
535
+
536
536
If `--%beforeeach` raises an unhandled exception the following will happen:
537
537
- the following `--%beforeeach` as well as all `--%beforetest` for that test **will not be executed**
538
538
- the test will be marked as errored and exception stack trace will be captured and reported
@@ -613,7 +613,7 @@ The procedure annotated as `--%aftereach` is getting executed after each test in
613
613
That means that the procedure will be executed as many times as there are test in suite package.
614
614
615
615
If a test is marked as disabled the `--%aftereach` procedure is not invoked for that test.
616
-
616
+
617
617
If `--%aftereach` raises an unhandled exception the following will happen:
618
618
- the test will be marked as errored and exception stack trace will be captured and reported
619
619
- the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test
@@ -691,7 +691,7 @@ Used alongside `--%test` annotation. Indicates procedure name to be executed bef
691
691
The `--%beforetest` procedures are executed after invoking all `--%beforeeach` for a test.
692
692
693
693
If a test is marked as disabled the `--%beforetest` procedure is not invoked for that test.
694
-
694
+
695
695
If `--%beforetest` raises an unhandled exception the following will happen:
696
696
- the following `--%beforetest` for that test **will not be executed**
697
697
- the test will be marked as errored and exception stack trace will be captured and reported
@@ -773,7 +773,7 @@ Used alongside `--%test` annotation. Indicates procedure name to be executed aft
773
773
The `--%aftertest` procedures are executed before invoking any `--%aftereach` for a test.
774
774
775
775
If a test is marked as disabled the `--%aftertest` procedure is not invoked for that test.
776
-
776
+
777
777
If `--%aftertest` raises an unhandled exception the following will happen:
778
778
- the test will be marked as errored and exception stack trace will be captured and reported
779
779
- the following `--%aftertest` and all `--%aftereach` procedures **will be executed** for the errored test
@@ -858,7 +858,7 @@ With this comes a challenge. How to group tests, related to one tested procedure
858
858
This is where utPLSQL contexts come handy.
859
859
860
860
Contexts allow for creating sub-suites within a suite package and they allow for grouping of tests that are somehow related.
861
-
861
+
862
862
In essence, context behaves like a suite within a suite.
863
863
864
864
Context have following characteristics:
@@ -869,10 +869,10 @@ Context have following characteristics:
869
869
-`--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at suite level, propagate to context
870
870
- test suite package can have multiple contexts in it
871
871
- contexts cannot be nested
872
-
872
+
873
873
874
874
The below example illustrates usage of `--%context` for separating tests for individual procedures of package.
875
-
875
+
876
876
Tested tables and code
877
877
```sql
878
878
createtablerooms (
@@ -1179,15 +1179,30 @@ Keep in mind that when your test runs as autonomous transaction it will not see
1179
1179
1180
1180
### Throws
1181
1181
1182
-
The `--%throws` annotation allows you to specify a list of exception numbers that can be expected from a test.
1182
+
The `--%throws` annotation allows you to specify a list of exception either by numbers or by exception type that can be expected from a test.
1183
1183
1184
1184
If `--%throws(-20001,-20002)` is specified and no exception is raised or the exception raised is not on the list of provided exception numbers, the test is marked as failed.
1185
1185
1186
1186
The framework ignores bad arguments. `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`.
1187
1187
The annotation is ignored, when no valid arguments are provided `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`.
1188
1188
1189
+
The framework allows to pass exception defined in variables for example constants in other packages or as exceptions `--%throws(exc_pkg.c_exc_variable)`
1190
+
1191
+
Please note that NO_DATA_FOUND is a special case and it will be translated into -1403.
1192
+
1189
1193
Example:
1190
1194
```sql
1195
+
create or replace package exc_pkg is
1196
+
c_e_option1 constant number :=-20200;
1197
+
c_e_option2 constant varchar2(10) :='-20201';
1198
+
c_e_option3 number :=-20202;
1199
+
1200
+
e_option4 exception;
1201
+
pragma exception_init(e_option4, -20203);
1202
+
1203
+
end;
1204
+
/
1205
+
1191
1206
create or replace package example_pgk as
1192
1207
1193
1208
--%suite(Example Throws Annotation)
@@ -1207,6 +1222,26 @@ create or replace package example_pgk as
1207
1222
--%test(Gives failure when an exception is expected and nothing is thrown)
1208
1223
--%throws(-20459, -20136, -20145)
1209
1224
procedure nothing_thrown;
1225
+
1226
+
--%test(Throws package exception option1)
1227
+
--%throws(exc_pkg.c_e_option1)
1228
+
procedure raised_option1_exception;
1229
+
1230
+
--%test(Throws package exception option2)
1231
+
--%throws(exc_pkg.c_e_option2)
1232
+
procedure raised_option2_exception;
1233
+
1234
+
--%test(Throws package exception option3)
1235
+
--%throws(exc_pkg.c_e_option3)
1236
+
procedure raised_option3_exception;
1237
+
1238
+
--%test(Throws package exception option4)
1239
+
--%throws(exc_pkg.e_option4)
1240
+
procedure raised_option4_exception;
1241
+
1242
+
--%test(Raise name exception)
1243
+
--%throws(DUP_VAL_ON_INDEX)
1244
+
procedure raise_named_exc;
1210
1245
1211
1246
end;
1212
1247
/
@@ -1230,39 +1265,73 @@ create or replace package body example_pgk is
When processing the test suite `test_employee_pkg` defined in [Example of annotated test package](#example), the order of execution will be as follows.
0 commit comments