11
votes

I'm using IntelliJ 2017.3 to measure the code coverage of my tests. The code base contains some more or less dumb classes that should be excluded from this measurement. I want to exclude all classes which contain Factory as part of their name (example: AverageOperatorFactoy) and tried it with the patterns *Factory and .*Factory (although it seems like regex are not used here), but IntelliJ still shows factories in the coverage report.

How can I exclude classes with a name pattern?

enter image description here

1
Could you please share some example names of test classes? It's hard to guess what kind of regular expression should be used, if an output is unknown. - Kamil
I've added a name as example. - deamon

1 Answers

4
votes

I have the same issue using a very basic pattern like

com.example.myproject.somecode.*

While including works as expected, excluding has no effect at all.

This is seems to be a known issue in IntelliJ. See Code coverage Report includes excluded packages

If you don't have too many packages in your project, you could still do the opposite and include only those packages you want using several active include patterns together.

Alternatively you can use the now free IntelliJ plugin Open Clover which offers much better coverage configuration and result browsing than IntelliJ ships with.