IntelliJ IDEA 6.0: Code Coverage
In forthcoming IntelliJ IDEA 6.0 release a new tool will be available. It aims to measure the code coverage for your unit tests or tests written as simple applications with the main() method. The engine that performs code coverage in IntelliJ IDEA is based on the EMMA open-source toolkit.
The feature as implemented by IntelliJ IDEA brings several technical innovations to the Java code coverage field.
The most important of them are:
- On-the-fly code coverage execution with no classes pre scanning phase
IntelliJ IDEA has no need in static classes instrumentation making use of instrumentation concept introduced in Java 5.0. Moreover, IntelliJ IDEA already knows the structure of your project, so it can calculate the package coverage statistics based not only on those classes that have been instrumented, but taking into account all compiled classes for the package. Essentially this brings lazy coverage calculation concept into action and ensures low run time overhead.
- Correct coverage information displayed for files edited after coverage statistics has been gathered
How is it possible? Well, again this is a result of a tight integration of coverage support with the rest of IntelliJ IDEA infrastructure. Here the result is obtained by collecting the information on the difference between the current file version and the one created at the moment coverage was run (taken from the local VCS).
To get the feeling of the code coverage, you just need to configure this feature and run your tests or applications. You can access this feature by selecting Run | Edit Configurations (or by pressing Shift + Alt + F10). The Run/Debug Configurations dialog appears where you can enable and configure the feature.
To run the coverage measuring, simply run or debug the configuration.
Whereupon, the statistics on the lines covered can be displayed in the Project View by selecting View-> Show Coverage Information or pressing Ctrl+Alt+F6 in the default keymap.
Also right in the editor you’ll see whether the lines were covered or not (they are marked green and red, respectively). The yellow mark indicates that the line was executed “partially”, for example, if only one condition from the if statement was checked.
The feature is already available in the latest EAP version. Join EAP now!
Subscribe to Blog updates
Thanks, we've got you!
Java Annotated Monthly – October 2023
Welcome to the October edition of Java Annotated Monthly! In this issue, we're plunging into the world of Java and tech. We'll explore the latest and greatest in the recent release of Java 21, share exciting news about the new EAP for IntelliJ IDEA 2023.3, and bring you a handpicked selection of …
JPA and React Plugins: From Buddies To Full Members of The JetBrains Family
We are excited to announce that JPA Buddy and React Buddy have joined the JetBrains family. Positioned as powerful plugins for working with JPA data and React applications, respectively, they will offer even more functionality for IntelliJ IDEA and WebStorm developers moving forward. With this ac…
Java Annotated Monthly – September 2023
The September edition of Java Annotated Monthly is here! With this month’s release of Java 21 approaching, we're excited to bring you a final sneak peek into its crucial features. But that's not all! This edition is packed with helpful articles about cutting-edge AI technologies, including update…
Java Annotated Monthly – August 2023
The August edition of Java Annotated Monthly is here! As usual, we’ve selected a collection of fascinating articles covering the latest Java-related news, tech updates, AI and machine learning innovations, and more. We're thrilled to share the exciting news of the recent release of IntelliJ IDEA 202…