Previous | Next
Topic: Testing a procedure and not a function, 2 Attachments
Conf: 537, Msg: 38022
From: Steven Feuerstein (steven@stevenfeuerstein.com)
Date: 9/26/00 01:30 PM

Testing a procedure and not a function Steven Feuerstein sfeuerstein steven@stevenfeuerstein.com If you are testing a procedure, then you run the procedure first and after that execute the appropriate utAssert program to check the results. Below find an example of a unit test I wrote for an encapsulated DELETE operation (I have attached the entire package):

PROCEDURE ut_del1
IS
fdbk PLS_INTEGER;
BEGIN
/* Delete that finds now rows. */

EXECUTE IMMEDIATE '
DELETE FROM ut_DEL1
WHERE employee_id = -1
';
te_employee.del (-1, rowcount_out => fdbk);
-- Test results
utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1');
/* Successful delete */

EXECUTE IMMEDIATE '
DELETE FROM ut_DEL1
WHERE employee_id between 7800 and 7899
';

FOR rec IN (SELECT *
FROM employee
WHERE employee_id BETWEEN 7800 AND 7899)
LOOP
te_employee.del (
rec.employee_id,
rowcount_out => fdbk
);
END LOOP;

-- Test results
utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1');
ROLLBACK;
EXCEPTION
WHEN OTHERS
THEN
utassert.this (
'DEL1 exception ' || SQLERRM,
SQLCODE = 0
);
END;

I hope that helps...SF

Click to open! (722 bytes)

Click to open! (23,361 bytes)