Skip to content

Instantly share code, notes, and snippets.

@ran488
Created May 24, 2011 21:04
Show Gist options
  • Save ran488/989688 to your computer and use it in GitHub Desktop.
Save ran488/989688 to your computer and use it in GitHub Desktop.
Easyb testing for PL/SQL
package com.XXXXX.XXX.plsql
import groovy.sql.Sql
description """
Prototype of PL/SQL unit testing using Easyb.
Have full access to the Groovy libraries so we can avoid the messy JDBC baggage.
"""
scenario "Writing log message to APPL_LOG table via XXX.WRITE_APPL_LOG procedure",{
given "XXX.WRITE_APPL_LOG procedure written in PL/SQL", {
println "Setting up database connection..."
db = [url:'jdbc:oracle:thin:@XXXdev2.XXXXX.com:1521:XXXd10g',
user:'XXX',
password:'XXX',
driver:'oracle.jdbc.driver.OracleDriver']
sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
}
when "procedure is invoked", {
println "Calling procedure..."
plsqlCall = "{ call XXX.WRITE_APPL_LOG(?,?,?,?) }"
params = [ 'UT','INFO','Test message from automated test suite','UT-101' ]
sql.call(plsqlCall, params)
}
then "The log entry should be written to XXX.APPL_LOG table", {
verify = "SELECT * FROM XXX.APPL_LOG WHERE SOURCE = 'UT' and CORRELATION_ID = 'UT-101'"
results = sql.rows(verify)
results.each { r ->
println r
}
results.size.shouldBe(1)
}
}
println "Clean up after test run - delete the record we added..."
sql.call "DELETE FROM XXX.APPL_LOG WHERE SOURCE = 'UT' and CORRELATION_ID = 'UT-101'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment