PsiElementFinder () { Set<String> ignoredMethods = ContainerUtil.newHashSet("getClassesFilter", "processPackageDirectories", "getClasses"); Method[] methods = ContainerUtil.findAllAsArray( PsiElementFinder.class.getDeclaredMethods(), m -> !ignoredMethods.contains(m.getName()) && !Modifier.isPrivate(m.getModifiers()) && !Modifier.isStatic(m.getModifiers())); PsiElementFinder mock = createMockBuilder(PsiElementFinder.class).addMockedMethods(methods).createMock(); expect(mock.findClasses(anyObject(), anyObject())).andReturn(PsiClass.EMPTY_ARRAY).anyTimes(); expect(mock.findPackage(eq("foo"))).andReturn(null); expect(mock.getSubPackages(rootPackage(), anyObject())).andReturn(PsiPackage.EMPTY_ARRAY); replay(mock); return mock; }