oracle PL/SQL 的代码覆盖率
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/152435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Code coverage for PL/SQL
提问by Matthew Watson
Does anyone have tools or experience with code coverage for PL/SQL. I believe this is possible using DBMS_PROFILER?
有没有人有 PL/SQL 代码覆盖率的工具或经验。我相信这可以使用 DBMS_PROFILER 实现吗?
回答by David Mann
http://www.toadworld.com/BLOGS/tabid/67/EntryID/267/Default.aspxhas info about checking code coverage using the PL/SQL profiler.
http://www.toadworld.com/BLOGS/tabid/67/EntryID/267/Default.aspx有关于使用 PL/SQL 分析器检查代码覆盖率的信息。
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.
有关在 9i 或 10g 上进行分析的一些有用信息包含在 Metalink 文章 243755.1“实施和使用 PL/SQL 分析器”中,以获取有关分析代码的信息。从文章底部获取 prof.zip,它有一个 profiler.sql,它将在分析运行后很好地格式化您的结果。
More 10g documentation is available here without a MetaLinka account: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_profil.htm
无需 MetaLinka 帐户即可在此处获得更多 10g 文档: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
如果您运行的是 11g,则此处记录了一个新的分层分析器:http: //download.oracle.com/docs/cd/B28359_01/appdev.111/b28424/adfns_profiler.htm
回答by Ira Baxter
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.
请参阅SD 测试覆盖率工具。我们即将发布一个 PLSQL 测试覆盖工具,其功能与我们的其他工具相同,包括一个用于在源代码顶部显示结果的 GUI,以及一个生成的覆盖报告,用于收集单个函数的详细信息以及汇总包。
EDIT 2/15/2011: PLSQL test coverage production tool is available.
编辑 2/15/2011:PLSQL 测试覆盖生产工具可用。
回答by cagcowboy
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.
不确定这是否正是您所追求的,但在 10g 之后,有一个工具可以进行静态 PL/SQL 代码分析。
Info here... http://www.psoug.org/reference/plsql_warnings.html
信息在这里... 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.
根据我的经验,到目前为止,它已经抛出了很多假阴性。
回答by Dilshod Tadjibaev
I found something useful on http://www.databasejournal.com/features/oracle/article.php/10893_2197231_3page.
我在http://www.databasejournal.com/features/oracle/article.php/10893_2197231_3页面上发现了一些有用的东西。
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;
回答by WW.
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.
您可以安装一个名为DBMS_profiler的包。有了这个,您可以启动配置文件,Oracle 会将数据存储在特殊表中。然后停止配置文件并从这些表中报告。