Automating Unit Tests for PL/SQL Using Gradle

on Tuesday 28 May 2013

Gradle strikes again:


Yes, it really was that easy!

The Oracle database
This post assumes that you have an Oracle database available. I used an Oracle 10g XE instance running on localhost to develop this post. XE is free to download and is sufficient for development purposes.

I had a SCOTT schema with the password "oracle" in the database and also installed the utPLSQL schema, which is a necessary step to following this example. To replicate what I done I recommend downloading the Oracle Developer Days VM.

NOTE: If you install the utPLSQL schema into an Oracle 10g XE database, make sure that you have granted access on UTL_FILE to public as explained here (remember to connect as sysdba when doing this otherwise it won’t work).

The structure I used for this example is:

.
|-build
|---build.gradle
|---ut_run.sql
|-src
|---main
|-----sql
|-------run.sql
|---test
|-----sql
|-------run.sql

2 comments:

EstyPrem said...

Intersting, but does not exit from sqlplus shell I think ...


586 rows selected.

> Building 0% > :importDBTerminate batch job (Y/N)? Y

C:\apps\test_scripts>

Sion said...

Hi EstyPrem,

It was a long time ago when I posted this, but you are absolutely correct. I think at the time I cheated this and added the EXIT; to the script. Apologies for the misdirection, I will update.

In the meantime a colleague has started writing a plugin:
https://github.com/iwarapter/gradle-utplsql-plugin

Feel free to contribute, as always the more the merrier!!

Post a Comment