void () { registerInspection(new FindElseBranchInspection()); @Language("JAVA") String text = "class X { void f() { if (this == null) {} else return; } }"; configureByText(JavaFileType.INSTANCE, text); WriteCommandAction.runWriteCommandAction(getProject(), () -> myEditor.getDocument().setText(text)); getEditor().getCaretModel().moveToOffset(getFile().getText().indexOf("if (") + 1); assertEmpty(doHighlighting(HighlightSeverity.ERROR)); List<IntentionAction> fixes = findStupidFixes(); IntentionAction fix = assertOneElement(fixes); fix.invoke(getProject(), getEditor(), getFile()); fixes = findStupidFixes(); assertEmpty(fixes); assertEmpty(doHighlighting(HighlightSeverity.ERROR)); fixes = findStupidFixes(); assertEmpty(fixes); }