wtPLSQL Project

wtPLSQL is a white-box testing framework for Oracle database objects.

Website Home Page

Demonstrations and Examples

Demonstrations and examples assume successful connection to an Oracle database with wtPLSQL installed. wtPLSQL Installation instructions are available on the wtPLSQL Releases page.

Test results from assertions can be queried from a set of wtPLSQL tables. The examples here will use the default reporting package called WT_TEXT_REPORT. This package displays test results using DBMS_OUTPUT.

The Basics

A login, or database session, is required to interact with the Oracle database. The SQL below will create a user that can run these examples. If you already have a database login, this is not necessary.

create user wtp_demo identified by wtp_demo
   default tablespace users
   quota unlimited on users
   temporary tablespace temp;

grant create session   to wtp_demo;
grant create type      to wtp_demo;
grant create sequence  to wtp_demo;
grant create table     to wtp_demo;
grant create trigger   to wtp_demo;
grant create view      to wtp_demo;
grant create procedure to wtp_demo;

The simplest check for a wtPLSQL installation is to select the “version from dual”.

Run this:

select wtplsql.show_version from dual;

And get this:


This shows the wtPLSQL version as 1.1.0.

Another simple test is an ad-hoc assertion. This test requires DBMS_OUTPUT. The results of this test are not recorded.

Run this:

set serveroutput on size unlimited format word_wrapped

   wt_assert.eq(msg_in          => 'Ad-Hoc Test'
               ,check_this_in   =>  1
               ,against_this_in => '1');

And get this:

PASS Ad-Hoc Test. EQ - Expected "1" and got "1"

This indicates:

Note: This ad-hoc test also demonstrates implicit data type conversion.

Create a Test Runner Package

A test runner package is central to running tests in wtPLSQL. The Test Runner page covers all the basics of creating a test runner package.

Database Object Tests

More interesting examples actually test database objects. Here are some examples.

utPLSQL 2.3 Examples

wtPLSQL was built with the utPLSQL “ut_assert” API. These examples were created from the original utPLSQL 2.3 examples without modifying the “ut_assert” calls

Website Home Page