Toad World® Forums

Code Coverage questions


#1

A user recently asked these questions, which I thought I would post, along with my answers:

  1. Is it correct that the “only” code coverage metrics that is provided is how many times a given line number in a given PL/SQL database object has been executed?

  2. We would also need a metric that would give a percentage of the code that is covered by at least one test case. Is this something that Quest is looking into providing in the future, eg version 2.0?

  3. What happens with the profiling that provide the code coverage data when the PL/SQL code being tested calls a view that in turn calls other PL/SQL? Will the other PL/SQL be part of the profile and hence the code coverage?

Regarding code coverage:

Our code coverage analysis is based on PL/SQL profiling, which will tell you how many times each line is executed and how much time it took to execute it.

The code coverage that ships with Code Tester shows both of these pieces of information. And the XML version of this report also contains this data. From this you can today perform you own rollup calculations (as identified in #2), but I have to tell you that I don’t think that this is a trivial proposition. Which lines in a program do you count? BEGIN and END? THEN? And depending on the formatting of your code, a single statement can stretch over N lines of code. So…

** We don’t think it will be too easy to come up with a useful number;
** We are looking at improving our code coverage report for 1.9 but have no defined specs for it.

When you profile, Oracle will indeed gather information about the current program being tested and all subprograms that are called. When we report on code coverage, we take the profiler data and extract the rows of information that are for that particular subprogram only, and not any other programs it calls.

Note that you can also complement our Code Coverage report with either your own Code Tester custom reports or queries/reports run directly against the PL/SQL profiler tables.

Finally, I am saddened to say that we identified some bugs in 1.8.1 of the Code Coverage report; it is incorrectly showing all lines in program even if the # of times executed = 0.

Please notify us if you would like a patch to address this problem.