Featured Webinar: Simplify Compliance Workflows With New C/C++test 2024.2 & AI-Driven Automation Watch Now

Person typing on computer

Java Code Coverage

Java Code Coverage

Rapidly achieve your code coverage goals and gain coverage visibility with Parasoft Jtest.

Screenshot of Jtest product tour.

Code Coverage Analysis

Use Parasoft Jtest to get broader visibility into what code you’re testing and what you missed. Jtest captures code coverage from all testing practices, from unit to integration to functional testing. By associating code coverage with specific tests, Jtest gives you visibility into what tests are providing test coverage of your application. Live unit testing and test impact analysis leverage the same coverage data to identify and run the specific subset of tests to validate recent code changes.

How Does It Work?

For unit testing, Jtest collects coverage data for unit tests that are run from different build systems (Ant, Maven or Gradle), IDEs (Eclipse and IntelliJ), and the most popular testing framework (JUnit). Jtest analyzes every line of code and marks it as covered if it was executed during the testing process. Total coverage is the ratio of covered lines to all the lines which could have been covered. Users can easily check if their code has been thoroughly tested by inspecting coverage reports, or check if they are meeting their code coverage requirements. Parasoft’s coverage report enables the user to easily identify the lines and portions of code that were not covered.

With Jtest, you can execute unit tests and capture code coverage either locally or within the CI/CD pipeline. Code coverage markers in source code within the IDE allow you to easily pinpoint which lines of code are covered during execution, helping to ensure thorough test coverage.
Jtest enables code coverage analysis at multiple levels, including method, class, file, and project. This allows you to identify areas with insufficient coverage so you can focus on adding additional tests where needed.

Code coverage data from integration and functional testing can be merged with code coverage from unit tests for a comprehensive view of overall code coverage. The process highlights uncovered lines of code and allows you to generate new test cases to bridge gaps and improve coverage metrics. To ensure adherence to development team policies, Jtest, coupled with the Parasoft Findings plugin, can automatically validate builds using quality gates configured with predefined metrics for overall code coverage and/or modified code coverage.

Finally, testing results can be published to Parasoft DTP, where coverage metrics across builds and various testing practices are analyzed in depth. A data-driven approach facilitates informed decision-making and supports continuous improvement across your projects.

To provide effective test traceability, Parasoft tracks the covered code per test—especially useful when a user wants to check exactly what’s tested by their test case or to ensure proper test isolation. For instance, if a unit test executes unintended code, that accesses locally stored files or modifies the environment, the user can stub or mock it.

Features

Benefit from the Parasoft Approach

Optimize testing

Parasoft Jtest identifies the beginning and end of each test so users can review coverage collected in a testing session for each executed test separately. This enables users to understand which tests to re-execute to optimize the testing practice.

Correlate coverage with manual and automated tests

Parasoft Jtest enables users to control the coverage collecting process in real time (for manual or automated functional tests) when coverage data is being collected. Users can start/stop test sessions, and download current coverage data in order to correlate coverage information with the test and the person doing the test.

Review coverage trends day-to-day and across builds

Parasoft Jtest enables users to view coverage trends over a period of time as well as compare coverage metrics build-over-build, to ensure quality is being met.