Unit Testing PL/SQL with DBUnit

PL/SQL is an Oracle’s procedural extension to SQL that allow to code the stored procedures in Oracle database. In this blog post, Nick Giles explains how he uses DbUnit to perform unit testing tor the stored procedures in Oracle. DbUnit is a JUnit extension (also usable with Ant) targeted at database-driven projects that, among other things, puts your database into a known state between test runs. In his solution Initial data and the expected output state of the tables containing the aggregated values are specified separately in two simple XML files. These are then referenced in a test method in a Java class along with the command to run the pre-calculation stored procedure. It worked so well that he could adopt a Test-Driven Development approach for his project.