Search code examples
javamavenintellij-ideafull-text-search

Intellij Idea fulltext search only in unit and integration test classes?


I have faced this problem recently and it took me a while to find out the solution, so I would like to share it here.

Assume a multi-module Maven project, each module having a standard directory structure:

  • src/main/java
  • src/main/resources
  • src/test/java
  • src/main/resources

Using IntelliJ Idea, how to perform a full-text in the test classes, i.e. mainly these with either *Test.java or *IT.java suffix and others (helpers with *DataHelper.java suffix) across the modules? The File Mask is not an option because it doesn't support logical operations (and, or, not) to find out.

The search scans all the directories across the project:

enter image description here


Solution

  • The small Scope tab is the key and could be missed at the first glance. The expanded drop-down list offers a variety of scopes to limit the search which can be used alongside the File Mask filter. The following selections can be easily overlooked:

    • For the test scope, select: Project test files
    • For the non-test scope, select: Project production files

    As long as the project is a Maven project, IntelliJ Idea can distinguish scope even for the full-text search.

    enter image description here