Code Coverage
Code Coverage
Optimizeit ™
i
ii
Chapter
Getting Started
Chapter 1
Note You can also access this wizard at any time from Tools|Java Setup.
1 If you want to use the default JRE, click Cancel, and the wizard returns you
to Optimizeit.
2 If you want to configure Optimizeit to use a different virtual machine, click
Next.
3 Select the directory where you want the wizard to search for available
virtual machines. The wizard scans the selected directory or drive and lists
all available virtual machines.
Tip After you see the message Found 1 virtual machine you can click Stop to
end the scan.
4 Select the virtual machine you want to use.
5 Click Next, then click Finish.
6 After changing the default virtual machine, Optimizeit prompts you to
confirm that the new default virtual machine should be used with the current
settings. Click Yes to start using that virtual machine.
are provided for all supported web and application servers. However, since
Optimizeit can be integrated with most application servers that use compatible
virtual machines, integration instructions are provided for manually integrating
Optimizeit with a variety of different servers.
Optimizeit also integrates with several integrated development environments
(IDEs) to help speed application development and test cycles.
See the Release Notes for a list of supported web and application servers, and
IDEs, and refer to the Optimizeit Integration Guide for integration instructions
and additional information. If you have trouble integrating your tool, see
Chapter 8, “Troubleshooting.”
When you first start Optimizeit, it opens the Edit Settings dialog box:
Use the Settings dialog box to modify your source path, class path, filters (if
any), and virtual machines. This dialog box is a centralized location for many
configuration items, which is convenient if you are testing a program from
within the Optimizeit user interface. You can also access the Settings dialog
box with the following File menu commands:
■ File|New —opens a new settings dialog box, with only the Optimizeit
defaults specified.
■
File|Open —allows you to browse for a settings file to use.
■
File|Open Recent —displays a list of recently accessed settings files
(generated by any Optimizeit tool) for you to choose from.
■ File|Settings—opens the current settings file, which you can either run
again or edit to run a new test.
The Settings dialog box contains the following pages:
■ Startup—this page contains the required elements for your configuration,
such as the program type, location, Class path and Source path.
■
Filters—if there are specific packages or classes you wish to test or ignore,
use the Filters page.
■ Virtual Machines—by default, Optimizeit tests with a Java 2 runtime. If you
want to specify a virtual machine other than the default, use the Virtual
Machines page.
Once you have configured the settings, you can save this configuration in a file
when you exit Optimizeit. By default, information from the last-saved settings
file is automatically loaded into Optimizeit when you open the program. The
same settings file can be used in Optimizeit Profiler, Code Coverage, or
Thread Debugger. Use the Save and Open commands on the File menu to
save settings files and access existing ones.
See also
■ Chapter 7, “Setting your preferences,” for more information about setting
defaults.
See also
■
“Connecting the audit system” on page 21 for remote testing instructions.
To add or change the source code location, click the Change button to bring
up the Source Path Chooser dialog box.
Use this dialog box to add, delete, and organize your source paths. Use the
browser to search for a specific directory or file, or use the empty field under
the browser if you have a multi-entry source path, such as c:\src;d:\project\
src.jar. Enter your full path information into the field. Specific files can also be
added later during the testing session. These additions apply only to the
current test program.
See also
■
By default, the Class Path dialog box contains the default class path as
defined by your CLASSPATH variable. This default can be changed using the
Preferences menu; see “Changing the class path” on page 46 for more
information.
■
By default, the Source Path dialog box is blank or contains the source path
defined using the Preferences menu; see “Setting the source code location”
on page 45 for more information.
2 Click the Filters tab on the Settings dialog box to open the Filter Editor:
3 To use inclusive filters, click Include Only. If you want to use exclusive
filters, click Exclude.
4 To add a pattern, click New. The Pattern Editor dialog box opens:
5 Enter your pattern in the box and click OK. Both the asterisk wildcard
character (*) and the not character (!) are supported. Your pattern can
define packages, classes, or methods. When you are done with this pattern
click OK.
6 Remove a pattern by highlighting it in the list and clicking Delete.
7 Edit a pattern by highlighting it in the list and clicking Edit Pattern. This
opens the pattern editor.
8 When you are done with your filter selection, click on the Virtual Machines
or Startup tabs, or click Start Now to begin your test. Click OK if you just
want to save your information.
Note If you select more than one filter for a test run, Optimizeit always performs a
logical OR of all the filters you have selected. Any top-level package, class, or
method that meets any of the filter criteria is filtered.
See also
■ “Using the Filter Editor” on page 22 for instructions on using the Filter Editor
executable when testing a remote application. This executable operates
outside the Optimizeit user interface.
Custom filters are part of Optimizeit configuration files. They are saved and
loaded when using Save and Open commands from the File menu.
The main panel lists all of the virtual machines Optimizeit recognizes on this
computer.
If you want to use a JIT (Just In Time compiler) when testing, check that
option.
If you aren’t sure which options to use, or you want to return to your defaults,
click Use Default Settings.
Once you have configured the Settings dialog box to start your application,
you can save this configuration in a file when you exit Optimizeit. By default,
information from the last-saved settings file is automatically loaded into
Optimizeit when you open the program. The same settings file can be used in
Optimizeit Profiler, Code Coverage, or Thread Debugger. Use the Save and
Open commands on the File menu to save settings files and access existing
ones.
command line
This chapter describes how to start, run, and configure Optimizeit from outside
the Optimizeit user interface. In addition to running your test program from
within Optimizeit, you can also run it from a command prompt.
Invoking your application from outside the Optimizeit user interface allows you
to do the following:
■ Set custom variables
■ Run the application as part of a script
■ Run the program on a different machine
Table 3.3 UNIX audit system Virtual Machine start options (continued)
Option Description
-Xrunoii Starts the Optimizeit Suite JVMPI agent. This
option is only available if you have Optimizeit
Suite installed. All Optimizeit command options,
including those that are tool-specific, can be used
with -Xrunoii.
-Xbootclasspath JDK 1.2 and newer only. Appends Optimizeit
/a:<OptItdir>/lib/oibcp.jar classes to the boot classes. Replace <OptItdir>
with the directory where you installed Optimizeit.
-native JDK 1.2 on Solaris platforms only. If your virtual
machine uses green threads you should
suppress the -native option and add -
DOPTITTHR=green and -DOPTITDIR=<OptDir>
(where <OptDir> is the directory where you
installed Optimizeit). The invocation becomes:
java -native -Xnoclassgc
-Djava.compiler=NONE
-DOPTITTHR=green
-DOPTITDIR=<OptItDir>
intuitive.audit.Audit ...
Examples
Use the following command to launch the applet contained in the file
example.html, without testing JDK classes and applet viewer classes.
On Windows:
oldjava -Xruncci:filter=<OptItDir>\filters\DefaultAllOn.oif
-Xbootclasspath/a:c:\Optimizeit\CCoverage\lib\oibcp.jar
intuitive.audit.Cover sun.applet.AppletViewer example.html
On Solaris or Linux:
oldjava -Xruncci:filter=<OptItDir>/filters/DefaultAllOn.oif
-Xbootclasspath/a:/opt/sfw/Optimizeit/CCoverage/lib/oibcp.jar
intuitive.audit.Cover sun.applet.AppletViewer
file:/usr/applet/example.html
Use the following command to test only the classes of the package com.busy of
the application com.busy.BusyApp and generate a snapshot when the application
ends.
On Windows:
java -Xruncci:filter=<OptItDir>\filters\DefaultAllOn.oif
-Xbootclasspath/a:c:\Optimizeit\CCoverage\lib\oibcp.jar
intuitive.audit.Cover -snapshotonexit com.busy.BusyApp
On UNIX:
java -Xruncci:filter=<OptItDir>/filters/DefaultAllOn.oif
-Xbootclasspath/a:/opt/sfw/Optimizeit/CCoverage/lib/oibcp.jar
intuitive.audit.Cover -snapshotonexit com.busy.BusyApp
The snapshotonexit option allows you to collect snapshot data. If you want to
see real-time data you must attach to the Optimizeit user interface, but if you
just want to collect snapshot data you do not need to attach the audit system
to the Optimizeit user interface. For example, if you want to generate a Code
Coverage snapshot report during nightly builds, you can insert a command in
your build script that will generate coverage data:
java -Xruncci:'filters={patternList=(!*tests.*,*Test*,*Proxy*)}'
-Xbootclasspath/a:/$optit_inst/lib/oibcp.jar intuitive.audit.Cover
-port 1472 -snapshotonexit mainClass
...
Because it is used for both Profiler and Code Coverage, the Filter Editor dialog
box has columns for both Profiler and Code Coverage filter operations. Only
one column, Ignore Coverage, is applicable for Code Coverage testing. Ignore
Coverage combines the two Code Coverage filter options, Include Class and
Exclude Class, into one column.
To use this program:
1 Make sure you have integrated with an application server and chosen your
virtual machine.
2 Start the Filter Editor:
■ If you are on a UNIX machine, go to your root Optimizeit directory and
enter ./Editfilter.sh at the command prompt.
■ If you are on a Windows machine, select the Optimizeit Filter Editor from
your Optimizeit program menu, or double-click on the Filter Editor
executable icon in your Optimizeit root directory.
3 The Filter Editor opens:
Click New to create a filter, or double-click on one of your filters to edit that
filter. You can also choose an existing filter from the Filter Editor File|Open
command to use as a starting point.
4 Check the applicable column(s) for your filter:
■ To filter methods, click in the Simplification Type column.
This column has two options:
■ Group: select the Group option to condense methods of multiple
classes into one single line in your stack trace. To use this option,
specify a set of classes to filter and give it a name as an identifier.
When you access the stack trace, all calls to the filtered methods are
condensed into one entry, labeled with the name you specified.
For example, if your unfiltered back trace lists classes such as:
org.apache.catalina.core.x...
org.apache.catalina.core.y...
org.apache.catalina.core.z...
javax.servlet.http...
Myservlet...
you can group your Apache classes under the name Apache classes,
and the filtered output for the same section shows:
Apache classes
javax.servlet.http...
Myservlet...
This is especially useful for servlets.
■
Eliminate: select Eliminate to filter these methods from your results.
The code matching this group is ignored, and will not show up in your
backtraces. The time spent in this eliminated group will be associated
with the caller.
Note The Eliminate simplification type is more efficient than Ignore CPU.
Typically, you should select Eliminate for Simplification Type, and not
enable Ignore CPU when enabling a filter.
■ To ignore CPU or time usage consumed by Java code matching the filter
pattern, click the Ignore CPU column.
Any time spent in the filtered method will be unaccounted for in the
backtrace. Ignore CPU is more precise than Eliminate, in that it assigns
the correct amount of time spent to the methods in the backtrace, but
Eliminate is useful in that all time is accounted for in the backtrace.
■ To enable a filter for the Memory Profiler, click the Ignore Memory
column. Optimizeit Profiler ignores object allocations performed by Java
code matching the filter pattern.
■ To enable a filter for a Code Coverage class, click the Ignore Coverage
column. This filter excludes a class from testing.
If you want the reverse (the equivalent of the Include Coverage filter
option in Code Coverage) use the not (!) character.
1 To see the patterns associated with a filter, double-click on the filter in the
table or highlight the filter and click Details.
2 Make your selections and chose the Filter Editor’s File|Save option to save
your filter file. This creates an .oif file that can be accessed by command-
line test runs.
Custom filters are part of Optimizeit configuration files. They are saved and
loaded when using Save and Open commands from the File menu.
Note If you select more than one filter for a test run, Optimizeit always performs a
logical OR of all the filters you have selected. Any top-level package, class, or
method that meets any of the filter criteria is filtered.
You can also create and edit filters in the Filter Editor. For information on how
to create and edit filters, see “Using the Filters tab” on page 9.
See also
■ For more information about Optimizeit Code Coverage Audit API, read the
API reference documentation.
Optimizeit Code Coverage has two ways to view results: Class Coverage and
Method Coverage. By default, when you start Optimizeit Code Coverage, the
Class Coverage view opens. To return to Class Coverage from Method
Coverage, click the Class Coverage button on the main menu bar.
Class Coverage lists all classes and the real-time test results for each class.
You can see how many lines have not been executed, and can apply filters to
test only certain classes.
Column Description
Class Name All the classes that will be tested with the selected filters. If a
class has not yet been loaded, Not Loaded appears on that
row.
Coverage % The percentage of coverage for each class. When the classes
have been compiled with line debug information (the default
when you use javac) this percentage represents the number
of lines of code that have been tested compared to the overall
number of lines of code for that class.
If the line debug information is not available (because the
classes were compiled with the -g:none option), this
percentage represents the number of methods from that class
that were executed compared to the total number of methods.
Tip: For more accurate test results, do not compile your
application using the -g:none option.
Diff. Similar to the Coverage column, but only shows the coverage
occurring since the last mark.
To sort the values in columns of the table, click on the column header.
The Filters box at the bottom allows you to select the classes that you want to
view. The classes that you exclude will still be tested, but Optimizeit will not
show them in the results.
Note This is different from the filters you set before the test is run, using the Filter
Editor. Those filters, contained in .oif files, select which classes are tested.
For example, to see only the classes from the com.sun.estore.inventory
package, enter the following in the filter box:
com.sun.estore.inventory.*
Both the asterisk wildcard character (*) and the not character (!) are
supported. It is also possible to enumerate more than one pattern using a
comma (,) separator. For example, to see all classes matching EJB except
those ending with Impl:
*EJB*, !*Impl
To see all tested classes, either clear the filter completely or type an asterisk
(*).
Starts or resumes the test program. This control is red when the test
program is running.
Pauses or resumes the test program. Use this button to freeze the
flow of execution to better study the interaction between different
parts of the tested program.
Stops testing. If you are running your test program from within the
Code Coverage user interface, the program will stop and the test will
end. If you are connected to a remote server, and the test program is
running on the remote machine, Stop will just disconnect your Code
Coverage user interface. The test program itself will keep running on
the remote server.
Click Mark to set a mark at any time. This resets the values in the Diff.
column of the Class Coverage table. If you set the mark before a
specific action in your application, you can see how this action affects
the testing of your classes.
Click Inspector to view the options for the Class Coverage display.
Once you have identified a class you would like to investigate in the Class
Coverage view, highlight this class in the table and either click the Method
Coverage button on the tool bar or double-click on the line in the Class
Coverage window. Optimizeit Code Coverage opens the Method Coverage
view.
Column Description
Method Name Name of the method
Note: This name includes the signature of the method if the
Show Method Signatures option in the Inspector is selected.
Coverage % Percentage of code tested for the method, computed as:
tested lines / total number of lines
for that method.
Note: If the class file for the selected class does not include
the debug line information, the method table only displays the
method name and invocation count. To include the line
information in your class files, use the -g option when
compiling.
Invocation Count Number of times the method has been called.
Missed Lines Number of lines not tested.
In the bottom pane, the source code table displays the source code for the
class being reviewed. The lines that have been tested are highlighted in
yellow. If you select any method in the method table, the source code table
displays that particular method.
The table contains these columns:
Column Description
# Line numbers in the file, retrieved from the debug line
information included in the class files. In the class file not all
lines of code are significant, so the compiler does not generate
bytecode for all the lines of code. The lines that do not
correspond to bytecode will have no number of calls reported
in the source code table and are disregarded when computing
the coverage.
Source code Percentage of code tested for the method, computed as:
tested lines / total number of lines
for that method.
Note: If Optimizeit Code Coverage cannot find the source file
for that class from the source path, it displays a message that
the source file could not be found. Click the Browse button to
search for the source file manually.
Calls Number of times each line of code has been called.
Note If the class file for the selected class does not include the debug line
information, the source code table displays a message explaining that the
class was compiled without the debug line information. To include the line
information in your class files, use the -g option when compiling.
You can refresh the values in the tables by selecting File|Reload.
Starts or resumes the test program. This control is red when the test
program is running.
Pauses or resumes the test program. Use this button to freeze the
flow of execution to better study the interaction between different
parts of the tested program.
Stops testing. If you are running your test program from within the
Code Coverage user interface, the program will stop and the test will
end. If you are connected to a remote server, and the test program is
running on the remote machine, stop will just disconnect your Code
Coverage user interface; the test program itself will keep running on
the remote server.
Click Mark on the tool bar to set a mark. This resets the Invocation
Count and Missed Lines columns in the method table, and the Diff
column in the source code table. The source code table only contains
a Diff column if you choose the Show Difference option in the
Inspector.
Click Inspector to view the options for Method Coverage display:
Reporting features
Chapter 6
Generating snapshots
At any time, Optimizeit Code Coverage allows you to save test information into
a snapshot. You can then reload the snapshot later for further analysis. This is
useful, for example, when you are testing several different classes in one test
pass. Snapshots are generated from within the Optimizeit user interface or
with a specific command option when running Code Coverage from the
command line.
To generate a snapshot
1 Choose File|Generate Snapshot.
2 In the Directory field, enter the directory where you would like the snapshot
to be saved.
3 In the Name field, enter the name for the snapshot.
4 If you would like to have the time and date added to the end of the name
you have chosen, check Append Time And Date When Saving.
5 Use the Notes area to add any comments.
6 Click Write Snapshot to create the snapshot.
To open a snapshot:
1 Choose File|Open snapshot or File|Open recent snapshots.
2 Double-click a recent snapshot, or highlight a snapshot and click Open, to
view the snapshot’s test results. It may take a few moments to load,
because a snapshot uses a VM to display data. The VM installed with
Optimizeit is used to load the snapshot.
3 You can navigate through all available modes, but you cannot perform real-
time actions such as starting or pausing the test run or setting a mark.
Snapshots are binary files that can only be opened from within Optimizeit user
interface. If your snapshot takes a long time to load, and your connection
times out before the load is completed, you can increase the connection time-
out using the Launch option from Edit|Preferences.
Merging snapshots
Code Coverage includes a command-line executable, Snapmerge.
Snapmerge creates merges of selected snapshots. This is useful, for
example, if you have QA teams testing different areas of the product. The QA
teams can merge their test snapshots to give a complete view of the tested
classes. To use:
1 Create a series of snapshots during a testing session. These snapshots
could be of different time points in your test session, or of different functions
in the same product.
2 Note the names of the snapshots you want to merge.
3 From a command prompt, access the root directory for your Optimizeit
installation. For example, /home/OptimizeitSuite.
4 Enter the following command:
snapmerge mergefile.snp snap1.snp snap2.snp snap3.snp
where mergefile is the name of the file for all the merged snapshots and
snapx are the filenames of the snapshots you want to merge. Include all file
extensions, or the program will not be able to access your files.
Any warnings are displayed by default. If you do not want to see any error
or warning messages, use -noWarnings in your command.
■ A command example on Windows:
c:\Optimizeit\OptimizeitSuite\snapmerge.exe snapmerged.snp
snapshot1.snp snapshot2.snp snapshot3.snp
This command merges the three snapshots c:\MyApp\snapshot1.snp, c:\
MyApp\snapshot2.snp and c:\MyApp\snapshot3.snp into the new snapshot c:\
MyApp\snapmerged.snp.
■ A command example on Solaris or Linux:
/user/local/OptimizeitSuite/snapmerge - noWarnings
/home/MyApp/snapmerged.snp /home/MyAp/snapshot1.snp
/home/MyApp/snapshot2.snp /home/MyApp/snapshot3.snp
This command merges the three snapshots /home/MyApp/snapshot1.snp, /
home/MyApp/snapshot2.snp, and /home/MyApp/snapshot3.snp into the new
snapshot /home/MyApp/snapmerged.snp and turns off Optimizeit snapmerge
warning and error messages.
5 To view your merged snapshot, re-enter Code Coverage.
Note Make sure you have stopped any testing sessions, because Code
Coverage cannot open snapshots when the virtual machine is running.
6 Choose one of the Open Snapshot commands from the File menu and
browse for your merge file.
7 Double-click on the merge file to open it in Code Coverage. You will see a
merge of test information from the snapshots you selected.
Any merged snapshot can be reopened in Optimizeit Code Coverage (see
“Generating snapshots” on page 35), merged again with other snapshots, or
used to generate a report.
Generating reports
Code Coverage supports both command line- and user interface-accessed
report functions.
1 In the Directory field, enter the directory where the report will be created.
2 In the Name field, enter the filename of the report.
3 Check Append Time And Date When Saving to have the current time and
date appended to the name of the report.
4 In the Generate Report As field, select which type of file is to be used for
the report: HTML or ASCII.
5 In the Options section, check the options you want to use for this report:
■
Check Include Method Coverage if the method coverage should be
included in the report. When this option is not selected, only coverage for
the classes is included in the report.
■ Check Include Source Code if the source code should be included in the
report.
■ Check Show Difference to include the Diff columns, showing the test
information since the last mark. Both class coverage and method
coverage marks are included.
■ Check Show Method Signature to include the signature in the name of
the method.
6 Add any additional text, such as a description of the context of the test
session, in the Notes field.
7 Click Write Report to generate your report.
After generating a report with the specified filename, Optimizeit Code
Coverage opens the report file in your default editor or web browser.
Option Description
-methodInfo Includes the method test information. For each
tested class, the report includes a table with the
test results for each method of the class.
-showDiff Includes the diff information, which is the test
information since the mark.
-showSignatures Displays the full name of methods, including their
signatures.
-reportType Should be followed by a document type (either
HTML or ASCII). Specifies the type of the report
generated. The default value is HTML.
Option Description
-verbose Prints information about the status of the report
generation.
-showSource Includes the source code (when available) and
line coverage for the tested classes. (This option
is only effective with the -methodInfo option.)
-sourcePath Should be followed by the path to the source files
of the classes tested. This option should be used
to specify the location of the source code when
the -showSource option is used.
Examples
The following command generates the report stressTest.html from the
snapshot stressTest.snp, including the method coverage information.
On Windows:
java intuitive.optit.coverage.ReportGenerator -methodInfo c:\Test\
stressTest.snp c:\Test\stressTest.html
On Solaris or Linux:
java intuitive.optit.coverage.ReportGenerator -methodInfo /home/jay/
Test/stressTest.snp /home/jay/Test/stressTest.html
The following command generates the report EJBs_coverage.html from the
snapshot test5.snp, including the method information. The methods display
with their full signature. The source code with line coverage information is
included. The source file for the tested classes is located under the directory
c:\EJB_src.
On Windows:
java intuitive.optit.coverage.ReportGenerator -methodInfo -
showSignatures -showSource -sourcePath c:\EJB_src test5.snp
EJBs_coverage.html
On UNIX:
java intuitive.optit.coverage.ReportGenerator -methodInfo -
showSignatures -showSource -sourcePath /home/jay/EJB_src test5.snp /home/
jay/EJBs_coverage.html
Exporting data
Optimizeit can export test data as ASCII, HTML, or Importable ASCII. After the
data is exported it can be printed, compared, and archived.
To export the contents of a screen:
2 In Export, choose the coverage type you want in your report, such as Class
Coverage or Method and Source Code Coverage. Your options will depend
upon what view is active.
3 In Export As, choose the output of the file format. Select HTML to produce
an HTML document that presents data in the same format as the Optimizeit
views. Select ASCII for a more compact file. Select Importable ASCII if you
expect to use the output as input to another tool.
4 In the Filename field, enter the full path name of the file.
5 If this file already exists, and you want to append the new data at the end of
the file, check Append Data At The End Of The File.
6 Use Title to insert a description at the top of the exported document.
7 If you wish, use the Comments section for information such as additional
text to distinguish this test from others.
8 Click OK to export the data.
After exporting the data into the specified file, Optimizeit opens the file with the
default editor or web browser.
This chapter describes how to use the Edit|Preferences menu option to set
defaults for Optimizeit Code Coverage. You can set these defaults:
■ Selecting default displays
■ Setting launch parameters
■ Setting the source code location
■ Changing the class path
■ Selecting a virtual machine
■ Configuring servlet support
Your choices will appear in the Settings dialog box, where they can be
customized for each applet or application you are testing.
The Preferences dialog box, Startup view determines the default mode once
testing begins. Click Default display to choose your default workspace, such
as Class Coverage or Console.
Click the After Startup, Open pull-down menu to choose which window opens
in the default workspace:
■ Settings Editor—choose Settings Editor if your settings change depending
upon which test case you are running.
■ Attach Panel—choose Attach Panel if you usually test your programs from
outside of Optimizeit.
■ Nothing—choose Nothing if you rarely change your default settings, and
want to go directly to the default view when you open Code Coverage.
Click OK to close the form. The next time you open Optimizeit, your new
defaults are activated.
Optimizeit uses a port to get the test information from the audit system running
in your application server. This port is only used by Optimizeit and is not
related to any port of your application server. The default value for that port is
1472. If you start your application with Optimizeit from a script, the port is
specified in the script. If you use the Optimizeit servlet to start the audit
system, the port is specified from the servlet.
Note When Optimizeit Code Coverage is testing an application, if a Java file is not
available, you will be prompted to locate the file. After you locate the missing
Java file, a dialog box prompts you to add the file’s directory to the default
source path.
To set a different source path for an applet, servlet, or application that you are
testing with Optimizeit Code Coverage, define the changes to the default
source path in the Settings dialog box.
■ Use the empty field under the browser if you have a multi-entry class
path, such as c:\classes;d:\project\xmlParser.jar. Enter your full path
information into the field.
6 Click the Down Arrow button to add your selection to the class path. If you
entered a class path string, Optimizeit adds all the entries to the class path.
7 Click the OK button.
8 Click the OK button again to close the Preferences dialog box.
3 Click Setup.
This starts the virtual machine wizard.
4 Click Next.
5 Select a directory.
Optimizeit will begin the search for a virtual machine from this point.
6 Click Search.
Optimizeit Code Coverage displays the virtual machines found.
7 Click Finish to add these virtual machines to the list of available virtual
machines.
8 Highlight the virtual machine you would like to be the default, and click OK
to set the default.
3 The Path To The Tomcat 4 Server Used field contains the current path to
your Tomcat installation, if any. You can enter a path or change the existing
path to point to this application, which is required for direct servlet/JSP
testing.
4 If you are unsure of the correct directory for your Tomcat application, click
Servlet Setup to open the Setup wizard and browse for the correct location.
5 Edit the Directory Used For Temporary Files field if the default location is
too small or is not easily accessible.
6 By default, Code Coverage filters out Tomcat classes so you can
concentrate on the testing of your application. Uncheck this option if you
need to see the interaction between your tested application and Tomcat
classes.
7 In the Tomcat configuration section, you can choose to either automatically
generate the server.xml file (the default option), or you can use an existing
server.xml file if you already have one that you have used for other Tomcat
operations. You can browse for the correct file and double-click to select it,
or you can enter it in the file path field directly.
8 When you start the direct testing of a servlet or JSP, Code Coverage runs
your servlet in a servlet runner. The default port used by the servlet runner
is 8080. If you have another application that already uses that port, change
the value of the port in the Port Used By Tomcat field.
9 Click OK to save your changes.
Troubleshooting
Chapter 8
C ha pt er 8 : T r ou bl es h oo ti ng 49
Sta r ting you r ap plicat ion
10 (UNIX only) I cannot start Optimizeit. The Optimizeit script fails with the
error Class not found: intuitive.optit....
11 (Solaris only) Does Optimizeit support JDK 1.2.x? When configuring
Optimizeit to use JDK 1.2.x, an error box reports that JDK is incompatible
with Optimizeit.
12 (Solaris only) Does Optimizeit support JDK 1.3? When configuring
Optimizeit to use JDK 1.3, an error box reports that JDK is incompatible
with Optimizeit.
1 My application starts correctly, but an alert explaining that Optimizeit
failed to attach is displayed.
Optimizeit uses a default connection time-out of 60 seconds on Windows or
20 seconds on UNIX machines to attach to the virtual machine.
In some environments, the Optimizeit audit system may require more than
the default time-out to initialize. If this happens, choose Edit|Preferences,
select the Launch section and increase the connection time-out value.
2 My application ran successfully, but the Optimizeit tools are not
working correctly. Most of the buttons are disabled, and the views do
not contain information.
Optimizeit’s audit system runs inside the same virtual machine as the
tested application. If the tested application ends, the virtual machine exits
and Optimizeit loses contact with its audit system and cannot retrieve data
(a Test program exited alert pops up in Optimizeit).
To resolve this problem, Optimizeit provides an option to disable the Java
method System.exit(). This option can be enabled either by using the VM
Cannot Exit or Disable Exit option in the Settings dialog box or by using the
command line option -noexit (java ... intuitive.audit.Audit -noexit ...).
That way the virtual machine will not exit when your application ends. Use
the Stop button in Optimizeit to exit the program when your testing is
complete.
If you are starting your test from the command line, or testing remotely, the
-Xrunoii argument uses the configuration of the Audit System Selector.
Make sure your Audit System Selector is not set to none. On Windows
machines, your selected tool appears in the Windows icon tray. The
Optimizeit icon is red for Profiler, green for Thread Debugger, and blue for
Code Coverage.
If you have integrated Optimizeit with an application server, make sure that
you are attaching the correct tool to the Audit process started with your
application server. If, for example, the Audit System Selector has the
Thread Debugger tool selected and you started your WebLogic tool with
Thread Debugger, then you must attach with the Thread Debugger tool.
3 When starting my application, I get an alert reporting a Class not
found.
This error is very likely related to a CLASSPATH setting problem. Open the
Settings dialog box, and make sure that the Class Path window includes
the paths to the packages and classes required by your application.
C ha pt er 8 : T r ou bl es h oo ti ng 51
Sta r ting you r ap plicat ion
C ha pt er 8 : T r ou bl es h oo ti ng 53
Sta r ti ng y ou r ap pl i c at i on s er v e r
used by Optimizeit and is not related to any port of your application server.
The default value for that port is 1470. If you start your application with
Optimizeit from a script, the port is specified in the script. If you use the
Optimizeit servlet to start the audit system, the port is specified from the
servlet. Make sure to use the correct port when you attach.
Make sure that the process running on the remote machine is running on
the port that you are attaching to. Also make sure that no other Optimizeit
user interface is trying to attach to that same audit system. Only one
Optimizeit user interface can attach to an audit system.
If you have other versions of Optimizeit, make sure that you have the same
versions of Optimizeit installed and running on both the host and remote
machine. For example, you cannot attach the Optimizeit Profiler 6.0 user
interface to an Optimizeit audit system from version 4.1.
If you change test parameters (for example, you check the Disable Memory
Profiler option), you must re-start your application server before beginning a
new test. You must also re-start your application server to connect with
another tool. For example, if you have been testing an application with
Profiler and want to run a test against the same application with Thread
Debugger, you must
a Shut down your Profiler test.
b Shut down your application server.
c Use the oiselector (Audit System Selector) to select Thread Debugger.
d Restart your application server.
e Start Optimizeit and attach to your test program.
For a test script, make sure that you use the correct -Xrun version for your
chosen tool: -Xrunpri for Profiler, -Xruncci for Code Coverage, and -Xruntdi
for Thread Debugger.
6 (Windows only) Starting an applet from JBuilder does not work.
Optimizeit displays virtual machine not found error messages.
When you define a new virtual machine within JBuilder, make sure to select
the executable java.exe in the bin directory, not in jre/bin.
Optimizeit uses oldjava.exe to start applets; this executable does not exist
inside the jre/bin directory.
C ha pt er 8 : T r ou bl es h oo ti ng 55
Prob le ms durin g t estin g
5 The Optimizeit GUI looks wrong. The text is clipped, the windows are the
wrong size.
6 Optimizeit seems to run slowly. Are there some strategies to improve
performance?
1 While testing my application, my application stops or crashes
unexpectedly.
Take a look at the external console. It may give more information on what
went wrong. If you do not have an external console, it means you have not
selected the Open A Console option in the Settings dialog box. Make sure
to select the option, and start the testing again.
Also, try running the same test using the default JDK installed with
Optimizeit. Sometimes, errors are related to the JVM used.
2 While testing my application, the application stops, the console
shows a java.lang.OutOfMemoryError.
The virtual machine ran out of memory. You can increase the size of the
java heap by using the extra java parameters -Xms and -Xmx. For example, -
Xms128m -Xmx128m sets the size of the java heap to 128 Mb.
If you are starting the testing from Optimizeit, add those parameters in the
Extra Java Parameters field on the Settings dialog box.
If you are starting your application from the command line, add those
parameters to your command. For example, the following command starts
the testing of BusyApp with the JDK 1.3, setting the size of the java heap to
256 Mb:
java -classic -Xrunoii:filter=<OptIt_Dir>/filters/DefaultAllOn.oif
-Xbootclasspath/a:<OptItDir>/lib/oibcp.jar -Xms256m -Xmx256m
intuitive.audit.Audit BusyApp
3 Why can’t I test applets with my JRE?
When you test applets with JDK 1.2 or 1.3, Optimizeit runs your applet in
the applet viewer using oldjava rather than java, to avoid security
exceptions. The JRE 1.2 and 1.3 do not include oldjava. This is why
Optimizeit requires a JDK to test applets.
However, you can still test applets with a JRE from Optimizeit by following
these steps:
a Edit the java.policy file of your JRE located under the lib\security
directory of your JRE.
b At the end of the file include the following lines:
grant codeBase "file:<OptItDir>/lib/optit.jar" { permission
java.security.AllPermission; };
c Replace <OptItDir> with the directory where you installed Optimizeit,
using / instead of \ (for example: c:/Optimizeit/OptimizeitSuite).
d Set the environment variable OI_APPLET_JRE to true.
4 (Windows only) During a testing session, the Optimizeit user interface
becomes unresponsive, and the Optimizeit window is all white.
This problem can occur if the Optimizeit user interface runs out of memory.
Optimizeit is a Java program. By default the virtual machine is created with
a minimum heap set to 8 Mb and a maximum heap set to 64 Mb.
You can override these default values by using the following environment
variables:
■ OIMINHEAP
■ OIMAXHEAP
These variables should be set to a new memory size. The notation should
be compatible with the virtual machine options -ms and -mx. For example,
12000 means 12000 bytes, 64K means 64 Kb and 64M means 64 Mb.
To increase the max heap to 128 Mb on Windows NT:
a From the Start menu, select the Settings menu and then Control Panel.
b Double-click on the System icon.
c Select the Environment tab.
d In the Variable field, enter OIMAXHEAP.
e In the Value field, enter 128M.
f Click on Set, and then Apply.
If increasing the heap size does not help, use the following procedure to
troubleshoot the issue:
g Open Windows Explorer.
h Browse and select the directory containing Optimizeit.
i Select the jre directory.
j Double click on startOptimizeit.bat to start Optimizeit with a console
window.
k Recreate the issue. Please send any error message / exception to
Borland Technical Support.
You may need to increase the console window buffer size to capture the
whole error message:
l Choose Properties from the console window.
m Select the Layout tab.
n Enter a larger value in the Screen buffer size height field.
5 The Optimizeit GUI looks wrong. The text is clipped, the windows are
the wrong size.
Some X-servers, including Exceed, have problems with Swing applications,
such as over-large fonts or wrong-sized windows. The best way to test
remotely is to run the Optimizeit GUI locally. If you test remotely from your
Windows platform on your UNIX machine, make sure to use Optimizeit for
Windows on the Windows platform.
To configure Exceed 7 to display the right fonts with Optimizeit:
C ha pt er 8 : T r ou bl es h oo ti ng 57
Un do i ng an i nt eg ra ti on ( W i nd ow s o nl y )
■ Open the Exceed Xconfig window from the Windows Start menu,
Hummingbird.../Exceed/Xconfig.
■
Double click the Font icon to open the Font Settings dialog box.
■
Click the Font Database button.
■
Unselect the Automatic Font Substitution option then click OK.
■
Restart Exceed.
6 Optimizeit seems to run slowly. Are there some strategies to improve
performance?
To improve Optimizeit performance:
■ Check the command line argument (shown in the console if you are
running from the user interface) and make sure there are no debugging
arguments passed into the JVM. The JVMPI and the debugging
interface cannot work simultaneously, so this will slow down
performance.
■
Are you using a Hotspot runtime? This can sometimes degrade
performance.
■ For Profiler, make sure you do not set the minimum heap size to a high
value. This causes the heap to be resized less often. For better
performance, use approximately a 4:1 ratio for RAM:Heap size. You can
use a 2:1 ratio as long as you also add RAM to cover non-heap VM use
and Optimizeit user interface overhead. disabling the garbage collector
will slow down the backtrace view in both Tree and Graph modes
because the instance count keeps increasing. This affects the time it
takes to compute the backtrace views.
■ For Profiler, you can improve performance by disabling the Memory
Profiler when you are testing CPU, or disabling the CPU Profiler when
you are testing memory use.
I nde x 59
F M
File Export options 38 Mark button 29, 33
filter box 28 merging snapshots 36
Filter Editor 22 method coverage
Filter Editor columns 23 button 31
filters mode 4
creating 9 window options 32
editing 11 method name column 32
methodInfo report option 39
G missed lines column 32
g N
none option 28
generate snapshot on exit 8 native start option 18
generating reports not character 11
from the command line 39
within Code Coverage 38 O
generating snapshots 35
oibcp.jar 26
H Open A Console 8
Optimizeit
highlight since mark option 33 Integration Guide 3
host name 22
Hotspot runtime 13 P
I Pattern Editor 11
pause button 29, 33
ignore coverage column 23 port 44
include only Filter option 11, 23 used between the audit system and UI 17, 19
inclusive filters 10 port number 22
Inspector button 29, 33 preferences 4
inspector options default class path 46
highlight since mark 33 default source code 45
real time 33 launch 44
show diff 33 servlet 48
show method signature 33 startup 43
installing Code Coverage 2 virtual machine 47
integrating Optimizeit 3 preferences menu 8, 43
Integration Guide 3 program
intuitive.audit 25 location 7
invocation count column 32 options 8
types 7
J working directory 7
JAR files 46 R
Java 2 runtime 3
Java runtime option 13 readme file 2
Java setup wizard 3 real time option 33
JIT compiler 13 Release Notes 2
remote application
L connecting the audit system 21
testing 7, 21, 22
launch parameters 44 Report button 38
location field 7
I nde x 61
62 Co de C ove ra ge Use r ’s Guid e