Unit Testing PL/SQL

This looks hairy, but very powerful. Unit testing Oracle procedures and functions using some custom PL/SQL functions. Looking at the examples makes me want to cry:

/*file ut_truncit.pkb */
CREATE OR REPLACE PACKAGE BODY ut_truncit
IS
   PROCEDURE ut_setup
   IS
   BEGIN
      EXECUTE IMMEDIATE
         'CREATE TABLE temp_emp AS SELECT * FROM employee';
   END;

PROCEDURE ut_teardown IS BEGIN EXECUTE IMMEDIATE ‘DROP TABLE temp_emp’; END; – For each program to test… PROCEDURE ut_TRUNCIT IS BEGIN TRUNCIT ( TAB => ’temp_emp’ , SCH => USER ); utAssert.eq ( ‘Test of TRUNCIT’, tabcount (USER, ’temp_emp’), 0 ); END ut_TRUNCIT; END ut_truncit; /

Notice the setup/teardown/test metaphor is all there, hidden under ugly layers of PL/SQL.

Permalink: http://blog.iandavis.com/2003/11/unit-testing-plsql/

Other posts tagged as programming, technology

Earlier Posts