Piotr Grudzień
Piotr Grudzień

Reputation: 189

How to manage unit tests with rollback with SQL Developer

I'd like to test my packages that change data. Every test should stay data intanct. I recently discover Unit Test Module in SQL Developer and try to savepoint on startup and rollback at teardown but with no success. Is there a good way to do that?

My environment: Oracle 10g DB with SQL Developer 4.2

Code: Startup was PL/SQL script BEGIN Savepoint sp; END; and Teardown was PS/SQL script BEGIN ROLLBACK to sp; END;

Upvotes: 0

Views: 302

Answers (2)

Piotr Grudzień
Piotr Grudzień

Reputation: 189

It took me 4 hours to discover that. It turns out that SQL Developer has a bug! It takes white signs/spaces after END; as a PLSQL code and puts pls-00103 begin function pragma procedure subtype type an identifier ERROR. My code above works like charm.

Upvotes: 1

John
John

Reputation: 3996

Most code that writes data uses some sort of framework that also manages transactions and commits and rollbacks. If this is the case you will need to use inverse operations to undo the updates you are testing with (i.e. test an insert operation, make your assertions, and then execute a delete operation).

Upvotes: 0

Related Questions