Intellij Idea : view test coverage on a maven project
Asked Answered
D

4

45

Is there a way to run all test in an root pom and collect test coverage in Intellij Idea ?

Doodlebug answered 19/6, 2013 at 10:28 Comment(3)
Do you mean a multi-module maven project?Coup
Yes, I mean a pom with multiple sub-poms.Doodlebug
These days this is only in UltimateWashin
C
49

Create a Run Configuration that will look for tests in the whole project. Make sure that you choose All in package and In whole project in the configurations dialog:

enter image description here

Make sure that you choose the <default> package in the Choose Package dialog.

enter image description here

Now you can select to run this configuration using Run 'All in project' with Coverage:

enter image description here

The result will be presented in a separate coverate window:

enter image description here

And you will also see the result in the Project View window for a fast overview:

enter image description here

Coup answered 19/6, 2013 at 12:59 Comment(0)
B
15

Right click on the parent module (root pom), and select Run 'All Tests' with Coverage.

enter image description here

Budge answered 19/6, 2013 at 16:5 Comment(2)
There is no such option when I right click on the root module. May be the problem is that this folder is not marked as source/test.Doodlebug
Works for me. Right-click the root directory where your pom.xml and src sit in.Unperforated
D
2

There is a 'Coverage' plugin, which may not be enabled by default.

Find it at File->Settings->Plugins.

This will enable the 'Run with Coverage' buttons and menu items.

A short official overview video is here: Code Coverage by IntelliJ IDEA

Dihydrostreptomycin answered 12/3, 2018 at 21:28 Comment(0)
A
0

To expand on ceilfors answer since it has slightly changed.

Right click on the test module -> More Run/Debug -> Run 'Tests in ...' with Coverage

This is with IntelliJ IDEA 2022.3.2 (Ultimate Edition)

Also the doc shows another way to do it: https://www.jetbrains.com/help/idea/running-test-with-coverage.html

Affixation answered 26/9, 2023 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.