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
Copy file name to clipboardExpand all lines: docs/userguide/annotations.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,19 +160,27 @@ A `%suitepath` can be provided in tree ways:
160
160
161
161
# Using automatic rollbacks in tests
162
162
163
-
By default, every test is isolated using savepoint.
163
+
By default, changes performed by every setup, cleanup and test procedure is isolated using savepoint.
164
164
This solution is suitable for use-cases, where the code that is getting tested as well as the unit tests themselves do not use transaction control (commit/rollback) or DDL commands.
165
+
165
166
In general, your unit tests should not use transaction control as long as the code you are testing is not using it too.
166
167
Keeping the transactions uncommitted allows your changes to be isolated and the execution of tests is not impacting others that might be using a shared development database.
167
168
168
169
If you are in situation, where the code you are testing, is using transaction control (common case with ETL code), then your tests probably should not use the default automatic transaction control.
169
170
In that case use the annotation `-- %rollback(manual)` on the suite level to disable automatic transaction control for entire suite.
170
-
If you are using nested suites, you need to make sure that thr entire suite all the way to the root is using manual transaction control.
171
+
If you are using nested suites, you need to make sure that the entire suite all the way to the root is using manual transaction control.
172
+
173
+
It is possible with utPLSQL to change the transaction control on individual suites or tests that are part of complex suite.
174
+
It is strongly recommended not to have mixed transaction control in suite.
175
+
Mixed transaction control settings will not work properly when your suites are using shared setup/cleanup with beforeall, afterall, beforeeach or aftereach annotations.
176
+
Your suite will most probably fail with error or warning on execution. Some of the automatic rollbacks will most probably fail to execute depending on the configuration you have.
171
177
172
178
In some cases it is needed to perform DDL as part of setup or cleanup for the tests.
173
-
It is recommended to move such DDL statements to a procedure with `pragma autonomous_transaction` to eliminate implicit commit of the main session.
179
+
It is recommended to move such DDL statements to a procedure with `pragma autonomous_transaction` to eliminate implicit commit in the main session that is executing all your tests.
174
180
Doing so, allows your test to use automatic transaction control of the framework and release you from the burden of manual cleanup of data that was created or modified by test execution.
175
181
182
+
When you are running test of code that is performing an explicit or implicit commit, you may set the test procedure to run in autonomous transaction with `pragma autonomous_transaction`.
183
+
Keep in mind, that when your tests runs in autonomous transaction it will not see the data prepared in setup procedure unless the setup procedure committed the changes.
0 commit comments