FileEditor (@NotNull JavaCodeInsightTestFixture fixture, @NotNull String fileName, @NotNull String fileText) { PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue(); EditorNotificationsImpl editorNotifications = (EditorNotificationsImpl)EditorNotifications.getInstance(fixture.getProject()); editorNotifications.completeAsyncTasks(); PsiFile psiFile = fixture.configureByText(fileName, fileText); FileEditorManager fileEditorManager = FileEditorManager.getInstance(fixture.getProject()); VirtualFile virtualFile = psiFile.getVirtualFile(); FileEditor[] editors = fileEditorManager.openFile(virtualFile, true); Disposer.register(fixture.getTestRootDisposable(), new Disposable() { @Override public void dispose() { fileEditorManager.closeFile(virtualFile); } }); assertThat(editors).hasSize(1); PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue(); editorNotifications.completeAsyncTasks(); return editors[0]; }