tags:

views:

1084

answers:

5

Does anyone have tools or experience with code coverage for PL/SQL. I believe this is possible using DBMS_PROFILER?

+1  A: 

Not sure if this is quite what you're after, but in 10g onwards there's a tool to do static PL/SQL code analysis.

Info here... http://www.psoug.org/reference/plsql_warnings.html

Note that it can be enabled at either session or database level.

In my experience it's thrown up quite a few false negatives so far.

cagcowboy
+1  A: 

I found something useful on http://www.databasejournal.com/features/oracle/article.php/10893_2197231_3 page.

select exec.cnt/total.cnt * 100 "Code% coverage"
from  (select count(1) cnt
      from plsql_profiler_data d, plsql_profiler_units u
      where d.runid = &&runid
      and u.runid = d.runid
      and u.unit_number = d.unit_number
      and u.unit_name = upper('&&name')
      and u.unit_owner = upper('&&owner')
      ) total,
     (select count(1) cnt
      from plsql_profiler_data d, plsql_profiler_units u
      where d.runid = &&runid
      and u.runid = d.runid
      and u.unit_number = d.unit_number
      and u.unit_name = upper('&&name')
      and u.unit_owner = upper('&&owner')
      and d.total_occur > 0) exec;
dt
A: 

There is a package you can install called DBMS_profiler. With this, you can start a profile and Oracle will store data in special tables. Then stop the profile and report from those tables.

WW
+1  A: 

http://www.toadworld.com/BLOGS/tabid/67/EntryID/267/Default.aspx has info about checking code coverage using the PL/SQL profiler.

Some helpful info about profiling on 9i or 10g is included in Metalink Article 243755.1 "Implementing and Using the PL/SQL Profiler" for information on profiling code. Grab the prof.zip from the bottom of the article, it has a profiler.sql which will nicely format your results after a profiling run.

More 10g documentation is available here without a MetaLinka account: http://download.oracle.com/docs/cd/B19306%5F01/appdev.102/b14258/d%5Fprofil.htm

If you are running 11g there is a new Hierarchical Profiler documented here: http://download.oracle.com/docs/cd/B28359%5F01/appdev.111/b28424/adfns%5Fprofiler.htm

David Mann
Update: After using the Hierarchical Profiler a bit this week it is not so useful for code covereage - it mainly collect data on the entry points of each function call and not on all lines of code like the original profiler.
David Mann
A: 

See SD Test Coverage Tools. We're about to release a PLSQL test coverage tool with the same capabilities as our other tools, including a GUI to display the results on top of your source code, and a generated coverage report that collects details on individual functions as well as rollups for packages.

Ira Baxter