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
- variables of type exception defined in a package specification - example `--%throws(exc_pkg.c_exception_No_variable)`
1185
+
- variables of type number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)`
1186
+
-[predefined oracle exceptions](https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#CIHFIGFE) - example `--%throws(no_data_found)`
1187
1187
1188
-
If `--%throws(-20001,-20002)` is specified and no exception is raised or the exception raised is not on the list of provided exceptions, the test is marked as failed.
1188
+
The annotation is ignored, when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`.
1189
1189
1190
-
The framework ignores bad arguments. `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`.
1191
-
The annotation is ignored, when no valid arguments are provided `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`.
1190
+
If `--%throws` annotation is specified with arguments and no exception is raised, the test is marked as failed.
1192
1191
1193
-
The framework allows to pass exception defined in variables for example constants in other packages or as exceptions`--%throws(exc_pkg.c_exc_variable)`
1192
+
If `--%throws` annotation is specified with arguments and exception raised is not on the list of provided exceptions, the test is marked as failed.
1194
1193
1195
-
Please note that NO_DATA_FOUND is a special case and it will be translated into -1403.
1194
+
The framework will raise a warning, when `--%throws` annotation has invalid arguments or when no arguments were provided.
1196
1195
1196
+
Annotation `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`.
1197
+
1198
+
Please note that `NO_DATA_FOUND` exception is a special case in Oracle. To capture it use `NO_DATA_FOUND` named exception or `-1403` exception No.
1199
+
1197
1200
Example:
1198
1201
```sql
1199
1202
create or replace package exc_pkg is
@@ -1212,7 +1215,7 @@ create or replace package example_pgk as
1212
1215
--%suite(Example Throws Annotation)
1213
1216
1214
1217
--%test(Throws one of the listed exceptions)
1215
-
--%throws(-20145,-20146, -20189 ,-20563)
1218
+
--%throws(-20145,bad,-20146, -20189 ,-20563)
1216
1219
procedure raised_one_listed_exception;
1217
1220
1218
1221
--%test(Throws different exception than expected)
@@ -1247,6 +1250,10 @@ create or replace package example_pgk as
1247
1250
--%throws(DUP_VAL_ON_INDEX)
1248
1251
procedure raise_named_exc;
1249
1252
1253
+
--%test(Invalid throws annotation)
1254
+
--%throws
1255
+
procedure bad_throws_annotation;
1256
+
1250
1257
end;
1251
1258
/
1252
1259
create or replace package body example_pgk is
@@ -1295,24 +1302,29 @@ create or replace package body example_pgk is
1295
1302
raise DUP_VAL_ON_INDEX;
1296
1303
end;
1297
1304
1305
+
procedure bad_throws_annotation is
1306
+
begin
1307
+
null;
1308
+
end;
1298
1309
end;
1299
1310
/
1300
1311
1301
-
exec ut.run('example_pgk');
1312
+
exec ut3.ut.run('example_pgk');
1302
1313
```
1303
1314
1304
1315
Running the test will give report:
1305
1316
```
1306
1317
Example Throws Annotation
1307
-
Throws one of the listed exceptions [.003 sec]
1308
-
Throws different exception than expected [.003 sec] (FAILED - 1)
1309
-
Throws different exception than listed [.004 sec] (FAILED - 2)
1310
-
Gives failure when an exception is expected and nothing is thrown [.004 sec] (FAILED - 3)
1318
+
Throws one of the listed exceptions [.002 sec]
1319
+
Throws different exception than expected [.002 sec] (FAILED - 1)
1320
+
Throws different exception than listed [.003 sec] (FAILED - 2)
1321
+
Gives failure when an exception is expected and nothing is thrown [.002 sec] (FAILED - 3)
1311
1322
Throws package exception option1 [.003 sec]
1312
-
Throws package exception option2 [.003 sec]
1313
-
Throws package exception option3 [.003 sec]
1314
-
Throws package exception option4 [.003 sec]
1315
-
Raise name exception [.003 sec]
1323
+
Throws package exception option2 [.002 sec]
1324
+
Throws package exception option3 [.002 sec]
1325
+
Throws package exception option4 [.002 sec]
1326
+
Raise name exception [.002 sec]
1327
+
Invalid throws annotation [.002 sec]
1316
1328
1317
1329
Failures:
1318
1330
@@ -1333,9 +1345,18 @@ Failures:
1333
1345
3) nothing_thrown
1334
1346
Expected one of exceptions (-20459, -20136, -20145) but nothing was raised.
0 commit comments