1- * plsql-codecoverage
1+ = plsql-codecoverage
22
33plsqlcodecoverage is a program to do code coverages of Oracle PL/SQL code
44running in the database. Currently only code coverage for packages is
55supported.
66
7- ** How it works
7+ == How it works
88The program creates the following database objects:
9- the tables
10- aaa_coverage
11- aaa_coverage_statements
12-
13- the sequence
14- aaa_coverage_seq
15-
16- and the package
17- aaa_coverage_tool
9+ the tables +aaa_coverage+ and +aaa_coverage_statements+,
10+ the sequence +aaa_coverage_seq+ and the package +aaa_coverage_tool+.
1811
1912The codecoverage process works by instrumenting the PL/SQL code, a logging
2013statement is placed before each statement.
2114
2215Example:
2316A function
17+ ----
2418function f2(x varchar2) return varchar2 is
2519begin
2620 return 'd'||x;
2721end;
28-
22+ ----
2923becomes
30-
24+ ----
3125function f2(x varchar2) return varchar2 is
3226begin
3327 "$log"(4);return 'd'||x;
3428end;
29+ ----
3530
36- The execution of the statments is logged into the tables aaa_coverage and
37- aaa_coverage_statements. Only the first execution of a statement is logged.
38- The original package state is stored in a clob in table aaa_coverage.
31+ The execution of the statments is logged into the tables + aaa_coverage+ and
32+ + aaa_coverage_statements+ . Only the first execution of a statement is logged.
33+ The original package state is stored in a clob in table + aaa_coverage+ .
3934
4035The codecoverage process is started for each package individually.
4136The codecoverage process works for all sessions that use the instrumented
@@ -52,60 +47,65 @@ Each schema/user has its own version of the database objects.
5247Needless to say that you should have a copy of your packages. Before instrumemting,
5348the original source code is saved into a clob, but one never knows.
5449
55- ** How to build
50+ == How to build
5651
5752plsqlodecoverage is currently developed as a netbeans project.
5853The platform is java 7, but the root classes are still java 8.
5954I use this setup for developing/debugging.
6055
6156The system can also be build with a simple ant build file:
62- build-plsqlcodecoverage.xml.
57+ + build-plsqlcodecoverage.xml+ .
6358
6459On windows you need an ant installation and you have to
65- set JAVA_HOME correctly. I do this with a configuration script
60+ set + JAVA_HOME+ correctly. I do this with a configuration script
6661which has these contents on my machine:
6762
63+ --------------------------
6864set java_home=C:\Program Files\Java\jdk1.8.0_25
6965set ant="C:\Program Files\NetBeans 8.0.1\extide\ant\bin\ant.bat"
7066set orajdbclib=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar
7167set jre7=C:\Program Files (x86)\Java\jre7
68+ --------------------------
7269
7370The variables orajdbclib is used in the build for obvious reasons.
74- The variable jre7 is used to set the bootclasspath.
71+ The variable + jre7+ is used to set the bootclasspath.
7572
7673To build the system, run
77- %ant% -f build-plsqlcodecoverage.xml dist|dist-fat|dist-lean
78-
79- The target dist creates a jar file psqlcodecoverage.jar in the directory dist.
80- The folder lib in the same directory contains the file ojdbc6.jar
81- which is referenced in the manifest of psqlcodecoverage.jar.
82-
83- The target dist-fat creates a jar file psqlcodecoverage.jar in the directory dist.
74+ ----
75+ %ant% -f build-plsqlcodecoverage.xml target
76+ ----
77+ where target is one of the following:
78+
79+ * +dist+: create a jar file +psqlcodecoverage.jar+ in the directory +dist+.
80+ The folder lib in the same directory contains the file +ojdbc6.jar+
81+ which is referenced in the manifest of +psqlcodecoverage.jar+.
82+ * +dist-fat+: create a jar file +psqlcodecoverage.jar+ in the directory dist.
8483This jar file contains the class files of the project as well as the class files
8584of the oracle jdbc library.
86-
87- The target dist-lean creates a jar file psqlcodecoverage.jar in the directory dist.
85+ * +dist-lean+: create a jar file +psqlcodecoverage.jar+ in the directory dist.
8886This jar file contains only the class files of the project. The user must supply the
8987Oracle jdbc classes via the classpath variable or command line.
9088If the oracle jdbc classes are not found during startup the user has to locate
9189the oracle jdbc jar file. The location is stored in the preferences.
92- If the program is started with the single argument " -clear-jdbc-file" the
93- location in the preferences is deleted.
90+ If the program is started with the single argument + -clear-jdbc-file+ the
91+ location stored in the preferences is deleted.
9492
95- ** How to use
93+ == How to use
9694Run the program with
95+ ----
9796java -jar psqlcodecoverage.jar
98-
97+ ----
9998If you are using the jar file created by the target dist, the lib directory
100- with the oracle jar file must be in the same directory as psqlcodecoverage.jar.
99+ with the oracle jar file must be in the same directory as + psqlcodecoverage.jar+ .
101100
102101If you are using the jar file created by the dist-lean target, you are asked
103102to locate the oracle jdbc jar file on first startup. The chosen location will
104103be saved.
105104Then you will be presented with a login dialog.
106- You can use two kind conenctions
107- fat: you just have to supply the tns name
108- thin: you have to supply host, port and service for the database
105+ You can use two kind connections
106+
107+ * *fat* you just have to supply the tns name
108+ * *thin* you have to supply host, port and service for the database
109109
110110In practice there are problems with the fat type connection.
111111Using this kind of connection loads a dynamic link/shared library into the
@@ -115,9 +115,10 @@ The thin connection is implemented in pure java and does not have this problem.
115115
116116The window shows the packages on the left.
117117The letter in front of a package is
118- V for packages that are valid but currently not covered.
119- I for packages that are invalid
120- C for packages that are covered
118+
119+ * *V* for packages that are valid but currently not covered.
120+ * *I* for packages that are invalid
121+ * *C* for packages that are covered
121122
122123The red-to-green square in front of a package indicates the coverage state
123124of a package, more green => more coverage.
@@ -135,4 +136,4 @@ The button stop/start coverage are used for starting code coverage and stopping
135136code coverage of the currenty selected package.
136137After a the code coverage of a package is stopped, the program still shows the
137138state of the last code coverage session. Even if the source code of the package
138- is changed.
139+ is changed.
0 commit comments