07 March 2013

PLSQL Unit Test

Continuing on my track of creating Ruby Gems to help with database interactions, I created PLSQL Unit Test. As the name suggests, it is designed to test PLSQL code.

It is a very simple gem, probably about 100 lines of code. It a nutshell it does three things:

  • Monkey patches Test::Unit::TestCase to add a few extra assert methods for testing the contents of database tables
  • Adds a method to create a database connection that is shared across all test classes
  • Loads Simple Oracle JDBC and Data Factory so they are available when coding tests.

The readme file and documentation bundled with the gem do a pretty good job of explain how it works, and I added an post to my Oracle blog giving an overview on how to get up and running.

As I write this, I have probably written about 400+ test cases using this framework, and it works well. It is certainly not an all singing and dancing test framework, as I only added features to cover scenarios I encountered as I was writing tests. The key for me when writing tests was to have a clean interface to communicate with the database (Simple Oracle JDBC) and a way to easily stage data (Data Factory) - after that Test::Unit provided almost everything I required.

blog comments powered by Disqus