void (PsiElement element, @NonNls String[] expectedFiles) { PsiReference[] refs = ReferencesSearch.search(element, GlobalSearchScope.projectScope(myProject), false).toArray( PsiReference.EMPTY_ARRAY); List<PsiFile> files = new ArrayList<>(); for (PsiReference ref : refs) { PsiFile file = ref.getElement().getContainingFile(); if (!files.contains(file)) { files.add(file); } } assertEquals(Arrays.toString(expectedFiles) + ".length != " + files + ".size()", expectedFiles.length, files.size()); Collections.sort(files, Comparator.comparing(PsiFileSystemItem::getName)); Arrays.sort(expectedFiles); for(int i = 0; i < expectedFiles.length; i++){ String name = expectedFiles[i]; PsiFile file = files.get(i); assertEquals(name, file.getName()); } }