Oracle DBMS_PLSQL_CODE_COVERAGE
Version 12.2.0.1

General Information
Library Note Morgan's Library Page Header
"I spent my entire adult life looking out for the well-being, the training, the equipping of the troops for whom I was responsible. I will not be lectured about what our military needs by a five-deferment draft dodger,"
~ Sen. Tammy Duckworth
Purpose Collects code coverage data for PL/SQL applications at the basic block level. A basic block is defined as a single entry single exit block of PL/SQL code in a user's program.

The user must supply a collection of filter_list_elem which is a schema, unit name pair for the list of units that the user is interested in gathering coverage information about.
AUTHID CURRENT_USER
Data Types type filter_list_elem IS RECORD(
  schema VARCHAR2(ORA_MAX_NAME_LEN+2),
  uname  VARCHAR2(ORA_MAX_NAME_LEN+2));

TYPE filter_list_type IS TABLE OF filter_list_elem;

SUBTYPE VARCHAR2_NOT_NULL IS VARCHAR2 NOT NULL;
Dependencies
DBMS_PLSQL_CODE_COVERAGE_LIB PLSQL_CODE_COVERAGE_RUNNUMBER USER_OBJECTS
DBMS_STANDARD    
Documented Yes
Exceptions
Error Code Reason
ORA-08402 Coverage error
First Available 12.2.0.1
Security Model Owned by SYS with EXECUTE granted to PUBLIC
Source {ORACLE_HOME}/rdbms/admin/dbmscov.sql
Subprograms
 
ANALYZE_COVERAGE (new 12.2)
Combines the data from multiple flushes within a run and writes the data to the coverage tables dbms_plsql_code_coverage.analyze_coverage(
directory    IN VARCHAR2,
filter_units IN filter_list_type,
delete_files IN BOOLEAN := FALSE);
DECLARE
 flt dbms_plsql_code_coverage.filter_list_type;
BEGIN

END;
/
 
CREATE_COVERAGE_TABLES (new 12.2)
  dbms_plsql_code_coverage.create_coverage_tables(force_it IN BOOLEAN := FALSE);
exec dbms_plsql_code_coverage.create_coverage_tables(TRUE);
 
FLUSH_COVERAGE (new 12.2)
Flushes the delta coverage data accumulated since the start of the run or the last flush operation to a file in the directory supplied during the start of the coverage run. dbms_plsql_code_coverage.flush_coverage;
exec dbms_plsql_code_coverage.flush_coverage;
 
RESET_COVERAGE (new 12.2)
Resets the coverage data accumulated since the last flush operation or the beginning of the run dbms_plsql_code_coverage.reset_coverage;
exec dbms_plsql_code_coverage.reset_coverage;
 
START_COVERAGE (new 12.2)
Starts coverage data collection at the basic block level in the user's session dbms_plsql_code_coverage.start_coverage(
directory   IN VARCHAR2,
run_comment IN VARCHAR2);
exec dbms_plsql_code_coverage.start_coverage('CTEMP', 'Code Coverage Run 1');
 
STOP_COVERAGE (new 12.2)
Stopping coverage flushes the coverage data to a file dbms_plsql_code_coverage.stop_coverage;
exec dbms_plsql_code_coverage.stop_coverage;
 
Demo
PL/SQL developers want to know how well their test infrastructure exercised their code. A typical code coverage run in a session will look like this conn sys@pdbdev as sysdba

CREATE DIRECTORY ctemp AS 'C:/TEMP';
GRANT ALL ON DIRECTORY ctemp TO uwclass;

conn uwclass/uwclass@pdbdev

-- create a proc or two here.

exec dbms_plsql_code_coverage.create_coverage_tables(

exec dbms_plsql_code_coverage.start_coverage(

-- run procs here

exec dbms_plsql_code_coverage.stop_coverage;

exec dbms_plsql_code_coverage.analyze_coverage;

- examine output here

Related Topics
Directories
Packages
What's New In 12cR1
What's New In 12cR2

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2017 Daniel A. Morgan All Rights Reserved