1
- * plsql-codecoverage
1
+ = plsql-codecoverage
2
2
3
3
plsqlcodecoverage is a program to do code coverages of Oracle PL/SQL code
4
4
running in the database. Currently only code coverage for packages is
5
5
supported.
6
6
7
- ** How it works
7
+ == How it works
8
8
The 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+.
18
11
19
12
The codecoverage process works by instrumenting the PL/SQL code, a logging
20
13
statement is placed before each statement.
21
14
22
15
Example:
23
16
A function
17
+ ----
24
18
function f2(x varchar2) return varchar2 is
25
19
begin
26
20
return 'd'||x;
27
21
end;
28
-
22
+ ----
29
23
becomes
30
-
24
+ ----
31
25
function f2(x varchar2) return varchar2 is
32
26
begin
33
27
"$log"(4);return 'd'||x;
34
28
end;
29
+ ----
35
30
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+ .
39
34
40
35
The codecoverage process is started for each package individually.
41
36
The 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.
52
47
Needless to say that you should have a copy of your packages. Before instrumemting,
53
48
the original source code is saved into a clob, but one never knows.
54
49
55
- ** How to build
50
+ == How to build
56
51
57
52
plsqlodecoverage is currently developed as a netbeans project.
58
53
The platform is java 7, but the root classes are still java 8.
59
54
I use this setup for developing/debugging.
60
55
61
56
The system can also be build with a simple ant build file:
62
- build-plsqlcodecoverage.xml.
57
+ + build-plsqlcodecoverage.xml+ .
63
58
64
59
On 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
66
61
which has these contents on my machine:
67
62
63
+ --------------------------
68
64
set java_home=C:\Program Files\Java\jdk1.8.0_25
69
65
set ant="C:\Program Files\NetBeans 8.0.1\extide\ant\bin\ant.bat"
70
66
set orajdbclib=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar
71
67
set jre7=C:\Program Files (x86)\Java\jre7
68
+ --------------------------
72
69
73
70
The 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.
75
72
76
73
To 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.
84
83
This jar file contains the class files of the project as well as the class files
85
84
of 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.
88
86
This jar file contains only the class files of the project. The user must supply the
89
87
Oracle jdbc classes via the classpath variable or command line.
90
88
If the oracle jdbc classes are not found during startup the user has to locate
91
89
the 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.
94
92
95
- ** How to use
93
+ == How to use
96
94
Run the program with
95
+ ----
97
96
java -jar psqlcodecoverage.jar
98
-
97
+ ----
99
98
If 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+ .
101
100
102
101
If you are using the jar file created by the dist-lean target, you are asked
103
102
to locate the oracle jdbc jar file on first startup. The chosen location will
104
103
be saved.
105
104
Then 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
109
109
110
110
In practice there are problems with the fat type connection.
111
111
Using 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.
115
115
116
116
The window shows the packages on the left.
117
117
The 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
121
122
122
123
The red-to-green square in front of a package indicates the coverage state
123
124
of a package, more green => more coverage.
@@ -135,4 +136,4 @@ The button stop/start coverage are used for starting code coverage and stopping
135
136
code coverage of the currenty selected package.
136
137
After a the code coverage of a package is stopped, the program still shows the
137
138
state of the last code coverage session. Even if the source code of the package
138
- is changed.
139
+ is changed.
0 commit comments