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
Java Best Practices
Good code follows certain rules, and knowing them increases your chances of success. We’d like to share some Java best practices that will help you on your way. We'll cover the must-know tips and tricks, from broad advice on software development to Java- and project-specific know-how. Let's get star…
The New Terminal (Beta) Is Now in JetBrains IDEs
The new terminal (Beta) is now in JetBrains IDEs and will be available in the new UI starting from the 2024.1 version of the IDEs.
Java Annotated Monthly – February 2024
Welcome to the February edition of Java Annotated Monthly! We're excited to share this month’s collection of articles brimming with the latest Java news, including a list of the upcoming JEPs for Java 22. What’s more, you’ll also get to explore numerous informative blogs packed with Java tips and tu…
Java Annotated Monthly – January 2024
Happy New Year and welcome to the January edition of Java Annotated Monthly! As we step into 2024, we're excited to bring you the latest news and tutorials from the tech world. This issue’s highlight is the release of IntelliJ IDEA 2023.3 – a real game-changer that introduces an AI Assistant feature…