129

Anyone knows how to exclude test files from find usages results ?

Like everything that is under : src/test/

Roman
  • 7,933
  • 17
  • 56
  • 72

6 Answers6

148

In the Find usages result panel, you can group by test/production. There is a button for that.

enter image description here

deamon
  • 89,107
  • 111
  • 320
  • 448
DagR
  • 2,900
  • 3
  • 24
  • 36
71

I found this answer extremely helpful:

https://stackoverflow.com/a/45958976/5449497

By putting !*Test.java into the File Mask textfield you can exclude Testfiles from your search results within the project.

Douy789
  • 1,015
  • 10
  • 16
57

Intellij Ultimate 11 version has an option to search in "Project production files".

Just press Alt+F7 on a usage and look on Scope.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Vic
  • 21,473
  • 11
  • 76
  • 97
42

IntelliJ IDEA Skip tests files pattern

You are able to create a custom search Scope

A scope is a subset of files, packages and/or directories in your project, to which you can limit the application of specific operations, e.g. search, code inspection, insertion of copyright notices, etc.

Edit -> Find -> Find Usages Settings...

enter image description here

Use pattern

!file:*Test.java or !file:*Test.java&&!file:*Tests.java or !test:*.*&&!test:*

All your scopes you can find

Android Studio -> Preferences -> Appearance & Behavior -> Scopes  

Also you can customise a pattern by using syntax

[Skip generated files pattern]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
  • 1
    In the current version of Jetbrains' IDEs, you have to click the "..." next to the scope dropdown and add a scope before you can fill in the pattern. – lortimer Feb 11 '22 at 15:25
1

BTW: I am using the latest version of Intellij 2020.3

steps to follow:

  1. Create your own Scope (Settings –> Appearance & Behaviour –> Scopes)

enter image description here

  1. Display Find Usages Settings dialog (Ctrl + Alt + Shift + F7)

  2. Select your custom scope from the dropdown menu and click on Find

  3. For the second time, Display Find Usages Settings dialog (Ctrl + Alt + Shift + F7)

Ikbel
  • 1,817
  • 1
  • 17
  • 30
0

Additionally, you can combine different conditions like this *.java,!*Test.java -> That is present in *.java files and do not include search from *Test.java files