Excluding unit tests from the "Unused Declaration" code inspection

The "Unused Declaration" code inspection is very useful for finding redundant code that is no longer used by your application and can be safely removed. The inspection fails, however, if there is a Unit test that exercises a method that is otherwise not used anywhere.

This makes the "Unused Declaration" inspection almost useless if you have a comprehensive test suite.

It would be great if the user could exclude the "tests" source tree from this inspection. So that if a method is only ever used in a Unit test the inspection will tell you it is unused.

2 comments

There's an option in Unused Declaration just for the case. Check "Add JUnit
tests to entry points" off.

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"David Bream" <saggerb@yahoo.com> wrote in message
news:29440616.1068785306420.JavaMail.itn@is.intellij.net...

The "Unused Declaration" code inspection is very useful for finding

redundant code that is no longer used by your application and can be safely
removed. The inspection fails, however, if there is a Unit test that
exercises a method that is otherwise not used anywhere.
>

This makes the "Unused Declaration" inspection almost useless if you have

a comprehensive test suite.
>

It would be great if the user could exclude the "tests" source tree from

this inspection. So that if a method is only ever used in a Unit test the
inspection will tell you it is unused.


-1

I've found that checking "Add JUnit tests to entry points" off only makes the test cases seem unused, not the code that the tests are covering properly show as unused. In short this suggestion did not help me.

0

Please sign in to leave a comment.