Code coverage for PL/SQL

后端 未结 5 404
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 22:55

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

相关标签:
5条回答
  • 2021-02-05 23:22

    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_01/appdev.102/b14258/d_profil.htm

    If you are running 11g there is a new Hierarchical Profiler documented here: http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28424/adfns_profiler.htm

    0 讨论(0)
  • 2021-02-05 23:34

    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;
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-05 23:47

    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.

    0 讨论(0)
  • 2021-02-05 23:49

    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.

    EDIT 2/15/2011: PLSQL test coverage production tool is available.

    0 讨论(0)
提交回复
热议问题