Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA: Exclude packages while running code coverage

Is there anyway we can exclude specific packages while running code coverage using IntelliJ IDEA as coverage runner? There is an option under Run/Debug Configurations > Coverage, that allows us to include classes/packages, but it would be very tedious to include about a few hundred packages to exclude just a few.

like image 575
Mariamj Avatar asked Feb 07 '16 18:02

Mariamj


People also ask

How do you exclude files from code coverage?

To exclude test code from the code coverage results and only include application code, add the ExcludeFromCodeCoverageAttribute attribute to your test class. To include assemblies that aren't part of your solution, obtain the . pdb files for these assemblies and copy them into the same folder as the assembly .

How do I stop running with coverage in IntelliJ?

To disable code coverage highlighting In the IDEA IDE, on the Analyze menu, click Show Code Coverage Data, or use the Ctrl+Alt+F6 keyboard shortcut. In the Code Coverage Suites dialog, choose No coverage.


1 Answers

There is probably no a way to match the packages that you want to include with a few wildcards? If you want to exclude one package from five packages (a, b, c, d, and e), this is the only option that I have found so far (in the "Run/Debug Configurations" dialog):

com.stackoverflow.a.*
com.stackoverflow.b.*
com.stackoverflow.d.*
com.stackoverflow.e.*

This is rather clumsy indeed.

When I run with code coverage (with a different configuration), the following output is shown:

D:\Programs\Java\jdk1.8.0_72\bin\java [...]
---- IntelliJ IDEA coverage runner ---- 
sampling ...
include patterns:
com\.stackoverflow\.q35257485\..*
com\.stackoverflow\.q34245660\.AnimatedBoxman(\$.*)*
exclude patterns:
Process finished with exit code 0

The "exclude patterns:" line gives the impression that it should be possible to exclude packages and/or classes, but I see no way to do this (in the "Run/Debug Configurations" dialog).

like image 95
Freek de Bruijn Avatar answered Oct 04 '22 01:10

Freek de Bruijn