How to configure code coverage to ignore lines?

We're using the IntelliJ IDEA code coverage runner. We've got some code within classes where we don't want the code coverage to run. Things like extreme conditions or places where writing a test to cover that very specific case just isn't possible.

Is there an annotation or "special comment" (eg., "// START CODE COVERAGE IGNORE", "// END CODE COVERAGE IGNORE") that we can apply?

Note that the case isn't where we want to exclude an entire package or class, just parts within classes.

Thanks,

jay

3 comments

Hi Jay,

not, it's impossible now.

IDEA's coverage works over bytecode so comments could be processed only in the editor and this would highly impact the productivity (persentage should be recalculated according to text). With annotations it could be done more efficiently but again - it would have its cost.

Do you need 100% coverage?

Thanks,
Anna

0

No, we don't need 100% percent coverage, but we do have a number of these cases which cause our coverage numbers to be lower than we'd like.

Also, I cannot figure out how to ignore certain files. We use GWT and have a number of JavaScriptObject-derived classes. There's just no way to write unit tests to cover them, so we want to ignore them. They're not in any one package. Is there any way to ignore files with names that match a given pattern?

Thanks,

jay

0

There is no UI for that.

You may run your configuration with -javaagent property copied from "Run with coverage" and pass there additional -exclude parameter (rexeps on classnames)

0

Please sign in to leave a comment.