[ Home | Getting Started | Build Test Packages | Examples | User Guide | Release Notes | Document Map ]
< Previous Section: utPLSQL Package | Next Section: utResult Package >
This package contains the following functions and procedures:
To make it as easy as possible for you to run your tests, utPLSQL stores various pieces of configuration data in the ut_config table. This data is stored by schema name and is automatically loaded into utPLSQL the first time you use this utility in your session. This configuration information is also automatically updated whenever you call utPLSQL.test -- or any of the utPLSQL programs specifically designed to change the configuration settings.
You can at any time view the utPLSQL configuration for the currently-connected schema or for another schema (there is not at this point any schema-level security; all utPLSQL users can view the configurations of all other users).
The data that is currently maintained for a utPLSQL user are:
Test package directory - the location of the test package code you want to run. You must specify a directory in order to allow utPLSQL to automatically compile your test packages before each test run.
Unit test prefix - the prefix used for test package names and the program names within the package. If you do not specify a prefix, the default of "ut_" is automatically applied.
Unit test registration mode - This setting determines whether utPLSQL will automatically identify the unit tests to be run (strongly recommended) or if you have chosen to manually register your unit tests in the test package setup procedure.
Auto-compilation of test packages - By default, utPLSQL will recompile your test package before execution. You can turn off this feature and manually recompile only when you desire (a fine idea if your test package has gotten very large!).
FUNCTION utConfig.tester RETURN VARCHAR2;
PROCEDURE utConfig.settester (username_in IN VARCHAR2 := USER);
PROCEDURE utConfig.showconfig (username_in IN VARCHAR2 := NULL);If you do not specify a schema, then the currently used configuration is returned. Here is an example of output from this procedure:
SQL> exec utconfig.showconfig ============================================================= utPLSQL Configuration for SCOTT Directory: /apps/utplsql/code Autcompile? Y Manual test registration? N Prefix = test_ =============================================================And here is an example of calling showConfig for a different schema:
SQL> exec utconfig.showconfig ('COMP')
=============================================================
utPLSQL Configuration for COMP
Directory: M:\shared_apps\utplsql\comp
Autcompile? N
Manual test registration? N
Prefix = ut_
=============================================================
You might want to put a call to showConfig in your SQL*Plus login file
so that you are reminded on startup as to what the current settings are.
Here is such a script (to be found in Examples\login_sample.sql):
exec utconfig.setdir ('e:\openoracle\utplsql\utinstall\examples')
SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED
exec utconfig.showconfig
Note: as of v1.5.1, the value you pass in any of these programs is saved in the configuration table and will be used in the future -- until you change it by passing a different value.
The header for this procedure is:
PROCEDURE utConfig.setdir (dir_in IN VARCHAR2, username_in IN VARCHAR2 := NULL);where dir_in is the directory and username_in is the name of the schema to which this directory applies (NULL means the currently used configuration is set), as in:
SQL> exec utconfig.setdir ('e:\demo\utplsql');
or, with the specification of a non-current schema:
SQL> exec utconfig.setdir ('e:\demo\utplsql', 'ANALYSIS');
Note that this directory must be accessible through UTL_FILE.
You might consider putting the the call to utConfig.setdir into your login.sql so that it is run automatically, each time your start up SQL*Plus -- if you are always working from the same directory.
FUNCTION utConfig.dir (username_in IN VARCHAR2 := NULL)
RETURN VARCHAR2;
The default prefix in utPLSQL is "ut_", but you can override this when you call utPLSQL.test or by calling the utConfig.setprefix procedure:
PROCEDURE utConfig.setPrefix ( prefix_in IN VARCHAR2, username_in IN VARCHAR2 := NULL)where prefix_in is the prefix and username_in is the name of the schema to which this prefix applies (NULL means the currently used configuration is set), as in:
SQL> exec utconfig.setPrefix ('tst#');
or, with the specification of a non-current schema:
SQL> exec utconfig.setPrefix ('t_', 'ANALYSIS');
FUNCTION utConfig.prefix (username_in IN VARCHAR2 := NULL)
RETURN VARCHAR2;
uPLSQL currently does not support the use of a suffix, or combination of
suffix and prefix, to identify test packages and unit test procedures.
If you so choose, you can request that utPLSQL turn off automatic detection of unit test procedures and only run those programs listed in the setup procedure. To do this, you call the utConfig.registerTest procedure:
PROCEDURE utConfig.registerTest (
onoff_in IN BOOLEAN,
username_in IN VARCHAR2 := NULL
);
as in:
SQL> exec utConfig.registerTest (TRUE)Note: if you are using automatic unit test detection, any calls to utPLSQL.addtest in the setup procedure will be ignored.
You can return the current registration mode using the following function:
FUNCTION registeringtest (username_in IN VARCHAR2 := NULL) RETURN BOOLEAN;This returns TRUE if the registration mode has been set to manual and FALSE otherwise.
BEGIN
-- Define a test suite for PL/Vision
utsuite.add ('PLVision');
-- Add two packages for testing
utsuite.addpkg (
'PLVision', 'PLVstr', dir_in => 'e:\utplsql');
utsuite.addpkg (
'PLVision', 'PLVdate', dir_in => 'e:\utplsql');
-- Run the test suite
utplsql.testsuite (
'PLVision', recompile_in => FALSE);
END;
/
If you know that you will never want to recompilation,
however, you can set the default behavior at the schema level by calling
the autocompile procedure
PROCEDURE utConfig.autocompile (
onoff_in IN BOOLEAN,
username_in IN VARCHAR2 := NULL
);
So I can make the following
call to turn off autocompilation for the SCOTT schema:
SQL> exec utconfig.autocompile (FALSE, 'SCOTT')This program updates the ut_config table with your information and then commits the setting.
You can determine the current setting for auto-compilation at any time by calling the following function:
FUNCTION utConfig.autocompiling (username_in IN VARCHAR2 := NULL)
RETURN BOOLEAN;
Note: When you set the schema-level recompilation
value to FALSE, that will override anything you pass in a call to utPLSQL.test
or utPLSQL.testsuite.
You can set the delimiter to be used in V2 procedure names using the following procedure:
PROCEDURE setdelimiter ( delimiter_in IN VARCHAR2, username_in IN VARCHAR2 := NULL );while the current delimiter can be obtained by the function:
FUNCTION delimiter (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;
By default, the results of all the tests are shown. This includes both successful and unsuccessful results. The following procedure allows you to limit the tests shown to only those that have failed:
PROCEDURE showfailuresonly (
onoff_in IN BOOLEAN,
username_in IN VARCHAR2 := NULL
);
the current setting can be obtained by the function:
FUNCTION showingfailuresonly (username_in IN VARCHAR2 := NULL)
RETURN BOOLEAN;
By default, all results are sent to the screen via DBMS_OUTPUT. However, it is possible to use other output reporters as described in more detail on this page. The following procedure allows you to set which output reporter should be used by default:
PROCEDURE setreporter (
reporter_in IN VARCHAR2
,username_in IN VARCHAR2 := NULL
);
as usual, the current setting can be obtain by the following function:
FUNCTION getreporter (username_in IN VARCHAR2 := NULL)
RETURN VARCHAR2;
< Previous Section: utPLSQL Package | Next Section: utResult Package >
Copyright (C) 2000-2005 Steven Feuerstein, Chris Rimmer, Patrick Barel All rights reserved