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
Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle REGEXP_LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF00501)
265
+
250
266
## equal
251
267
252
268
The equal matcher is a very restrictive matcher. It only returns true if the compared data-types are the same.
@@ -458,22 +474,44 @@ end;
458
474
459
475
This test will fail as `v_actual` is not equal `v_expected`.
460
476
461
-
## match
462
-
Validates that the actual value is matching the expected regular expression.
477
+
# Expecting exceptions
478
+
479
+
Below example illustrates how to write test to check for expected exceptions (thrown by tested code).
ut.fail('Expected exception but nothing was raised');
501
+
exception
502
+
when others then
503
+
ut.expect( sqlcode ).to_equal( -1476 );
504
+
ut.expect( sqlerrm ).to_match( 'equal to zero' );
505
+
end;
506
+
end;
507
+
/
473
508
```
474
509
475
-
Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle REGEXP_LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF00501)
510
+
The call to `ut.fail` is required to make sure that the test fails, if we expect an exception, but the tested code does not throw any.
511
+
512
+
The call to `ut.expect` uses `equal` matcher to check that the exception that was raised was exactly the one we were expecting to get in particular situation.
476
513
514
+
Depending on the situation you will want to check for `sqlcode`, `sqlerrm`, both or perform additional expectation checks to make sure nothing was changed by the called procedure in the database.
0 commit comments