Enable code coverage to detect lines and methods that have
not been exercised in your Java™ or
plugin project.
About this task
You can enable code coverage on any Java project in your workspace. In the Package
Explorer view, projects that are enabled for code coverage have the
following decorator:

Procedure
- Enable code coverage from either the Properties page or
the Run menu:
- On the properties page:
- Right-click the name of the project that you want to enable for
code coverage, and select Properties (or select .
- Click the Code Coverage property, select
the Enable code coverage check box, and optionally
select the Save Source check box. Click Apply.
- From the Run menu in the Code Coverage Enablement dialog box:
- Click . Select either All
projects or Only the selected projects (and
select the projects that you want enabled for code coverage), and
then click OK.
Note: With the Save
Source option, Code Coverage launch would capture the
current source code of the projects and save them along with code
coverage data. When opening Java source from the code coverage reports
on a selected launch, if the launch was run with the Save
Source option enabled, the editor will show the associated
source that had been saved at the time of the launched in read only
mode. If the Save Source option was not enabled
at the time of the launch, the Java source in the workbench will be
opened in edit mode. However, the source that is open might not match
with the source that was used to calculate code coverage if changes
to the source file happened after the launch. In addition, you should
enable the Save Source option if you are planning
to export the resulting code coverage as an archive so that the matching
version of source is saved with the code coverage data.
- Set code coverage levels and any filters.
What to do next
Important: If you are working with a remote
instance of WebSphere® Application
Server and the server is running, then you must restart the server
to enable it to collect code coverage statistics.
After you
enable code coverage on your project, coverage statistics will be
generated the next time that it is launched. Note that statistics
are not automatically generated for all types of launch configurations.