|
| 1 | +# Exception handling and reporting |
| 2 | + |
| 3 | +The utPLSQL is responsible for handling exceptions wherever they occur in the test run. utPLSQL is trapping most of the exceptions so that the test execution is not affected by individual tests or test packages throwing an exception. |
| 4 | +The framework provides a full stacktrace for every exception that was thrown. The stacktrace is clean and does not include any utPLSQL library calls in it. |
| 5 | +To achieve rerunability, the ORA-04068, ORA-04061 exceptions are not handled and test execution will be interrupted if such exception is encountered. This is because of how Oracle behaves on those exceptions. |
| 6 | + |
| 7 | +Test execution can fail for different reasons. The failures on different exceptions are handled as follows: |
| 8 | +* A test package without body - each `%test` is reported as failed with exception, nothing is executed |
| 9 | +* A test package with _invalid body_ - each `%test` is reported as failed with exception, nothing is executed |
| 10 | +* A test package with _invalid spec_ - package is not considered a valid unit test package and is excluded from execution. When trying to run a test package with invalid spec explicitly, exception is raised. Only valid specifications are parsed for annotations |
| 11 | +* A test package that is raising an exception in `%beforeall` - each `%test` is reported as failed with exception, `%test`, `%beforeeach`, `%beforetest`, `%aftertest` and `%aftereach` are not executed. `%afterall` is executed to allow cleanup of whatever was done in `%beforeall` |
| 12 | +* A test package that is raising an exception in `%beforeeach` - each `%test` is reported as failed with exception, `%test`, `%beforetest` and `%aftertest` is not executed. The `%aftereach` and `%afterall` blocks are getting executed to allow cleanup of whatever was done in `%before...` blocks |
| 13 | +* A test package that is raising an exception in `%beforetest` - the `%test` is reported as failed with exception, `%test` is not executed. The `%aftertest`, `%aftereach` and `%afterall` blocks are getting executed to allow cleanup of whatever was done in `%before...` blocks |
| 14 | +* A test package that is raising an exception in `%test` - the `%test` is reported as failed with exception. The execution of other blocks continues normally |
| 15 | +* A test package that is raising an exception in `%aftertest` - the `%test` is reported as failed with exception. The execution of other blocks continues normally |
| 16 | +* A test package that is raising an exception in `%aftereach` - all blocks of the package are executed, as ehe `%aftereach` is a closing block for an individual test. Exception in `%aftereach` is not affecting test results. For every failed execution of `%aftereach` a warning with exception stacktrace is displayed in the summary |
| 17 | +* A test package that is raising an exception in `%afterall` - all blocks of the package are executed, as the `%afterall` is the last step of package execution. Exception in `%afterall` is not affecting test results. A warning with exception stacktrace is displayed in the summary |
| 18 | + |
| 19 | + |
| 20 | +Example of reporting with exception thrown in `%beforetest`: |
| 21 | +```` |
| 22 | +Remove rooms by name |
| 23 | + Removes a room without content in it (FAILED - 1) |
| 24 | + Does not remove room when it has content |
| 25 | + Raises exception when null room name given |
| 26 | + |
| 27 | +Failures: |
| 28 | + |
| 29 | + 1) remove_empty_room |
| 30 | + |
| 31 | + error: ORA-20001: Test exception |
| 32 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 39 |
| 33 | + ORA-06512: at line 6 |
| 34 | + |
| 35 | +Finished in ,039346 seconds |
| 36 | +3 tests, 0 failed, 1 errored, 0 ignored. |
| 37 | +```` |
| 38 | + |
| 39 | +Example of reporting with exception thrown in `%test`: |
| 40 | +``` |
| 41 | +Remove rooms by name |
| 42 | + Removes a room without content in it (FAILED - 1) |
| 43 | + Does not remove room when it has content |
| 44 | + Raises exception when null room name given |
| 45 | + |
| 46 | +Failures: |
| 47 | + |
| 48 | + 1) remove_empty_room |
| 49 | + |
| 50 | + error: ORA-20001: Test exception |
| 51 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 48 |
| 52 | + ORA-06512: at line 6 |
| 53 | + |
| 54 | +Finished in ,035726 seconds |
| 55 | +3 tests, 0 failed, 1 errored, 0 ignored. |
| 56 | +``` |
| 57 | + |
| 58 | +Example of reporting with exception thrown in `%aftertest`: |
| 59 | +``` |
| 60 | +Remove rooms by name |
| 61 | + Removes a room without content in it (FAILED - 1) |
| 62 | + Does not remove room when it has content |
| 63 | + Raises exception when null room name given |
| 64 | + |
| 65 | +Failures: |
| 66 | + |
| 67 | + 1) remove_empty_room |
| 68 | + |
| 69 | + error: ORA-20001: Test exception |
| 70 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 42 |
| 71 | + ORA-06512: at line 6 |
| 72 | + |
| 73 | +Finished in ,045523 seconds |
| 74 | +3 tests, 0 failed, 1 errored, 0 ignored. |
| 75 | +``` |
| 76 | + |
| 77 | +Example of reporting with exception thrown in `%aftereach`: |
| 78 | +``` |
| 79 | +Remove rooms by name |
| 80 | + Removes a room without content in it |
| 81 | + Does not remove room when it has content |
| 82 | + Raises exception when null room name given |
| 83 | + |
| 84 | +Warnings: |
| 85 | + |
| 86 | + 1) test_remove_rooms_by_name - Aftereach procedure failed: |
| 87 | + ORA-20001: Test exception |
| 88 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 31 |
| 89 | + ORA-06512: at line 6 |
| 90 | + |
| 91 | + 2) test_remove_rooms_by_name - Aftereach procedure failed: |
| 92 | + ORA-20001: Test exception |
| 93 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 31 |
| 94 | + ORA-06512: at line 6 |
| 95 | + |
| 96 | + 3) test_remove_rooms_by_name - Aftereach procedure failed: |
| 97 | + ORA-20001: Test exception |
| 98 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 31 |
| 99 | + ORA-06512: at line 6 |
| 100 | + |
| 101 | +Finished in ,05071 seconds |
| 102 | +3 tests, 0 failed, 0 errored, 0 ignored. 3 warning(s) |
| 103 | +``` |
| 104 | + |
| 105 | +Example of reporting with exception thrown in `%afterall`: |
| 106 | +``` |
| 107 | +Remove rooms by name |
| 108 | + Removes a room without content in it |
| 109 | + Does not remove room when it has content |
| 110 | + Raises exception when null room name given |
| 111 | + |
| 112 | +Warnings: |
| 113 | + |
| 114 | + 1) test_remove_rooms_by_name - Afterall procedure failed: |
| 115 | + ORA-20001: Test exception |
| 116 | + ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 35 |
| 117 | + ORA-06512: at line 6 |
| 118 | + |
| 119 | +Finished in ,044902 seconds |
| 120 | +3 tests, 0 failed, 0 errored, 0 ignored. 1 warning(s) |
| 121 | +``` |
0 commit comments