Supplier<MadTestingAction> (CodeInsightTestFixture fixture, String rootPath, FileFilter fileFilter, BiConsumer<? super ImperativeCommand.Environment, ? super VirtualFile> action) { Generator<File> randomFiles = randomFiles(rootPath, fileFilter); return () -> env -> new RunAll( () -> { File ioFile = env.generateValue(randomFiles, "Working with %s"); VirtualFile vFile = copyFileToProject(ioFile, fixture, rootPath); PsiFile psiFile = fixture.getPsiManager().findFile(vFile); if (psiFile instanceof PsiBinaryFile || psiFile instanceof PsiPlainTextFile) { //noinspection UseOfSystemOutOrSystemErr System.err.println("Can't check " + vFile + " due to incorrect file type: " + psiFile + " of " + psiFile.getClass()); return; } action.accept(env, vFile); }, () -> WriteAction.run(() -> { for (VirtualFile file : Objects.requireNonNull(fixture.getTempDirFixture().getFile("")).getChildren()) { file.delete(fixture); } }), () -> PsiDocumentManager.getInstance(fixture.getProject()).commitAllDocuments(), () -> UIUtil.dispatchAllInvocationEvents() ).run(); }