Search code examples
javaintellij-ideajunit4

Intellij IDEA - Identifying all junit tests which are ignored


Can someone let me know is there a way I can identify all JUnit tests which are ignored i.e either @Ignore being added to the method or @Test is missing on the method in IntelliJ IDEA?

  • IDEA Version - 2017.2.2
  • JUnit - 4.12

Solution

  • Finding test classes which contain the @Ignore annotation can be done with Edit > Find > Find in Path ...

    enter image description here

    Finding test classes where "@Test is missing on the method" is trickier because any class can be a test class. Or to put it another way; a class is deemed a "test class" if (a) it is located in the test source tree and (b) it has at least one public method annotated with @Test. So, the absence of @Test would preclude a class from your search. So, perhaps you are looking for classes which meet these criteria:

    • Having at least one method annotated with @Test
    • Having at least one public method which is not annotated with @Test

    This would require a Structural Search, accessed from Edit > Find > Search Structurally. There are numerous canned templates available:

    enter image description here