void () { myFixture.configureByFile(getTestName(false) + ".groovy"); final int offset = myFixture.getEditor().getCaretModel().getOffset(); final PsiElement atCaret = myFixture.getFile().findElementAt(offset); final GrRangeExpression range = PsiTreeUtil.getParentOfType(atCaret, GrRangeExpression.class); final GroovyRangeTypeCheckInspection inspection = new GroovyRangeTypeCheckInspection(); final LocalQuickFix fix = inspection.buildFix(range); LocalQuickFix[] fixes = {fix}; final ProblemDescriptor descriptor = InspectionManager.getInstance(getProject()).createProblemDescriptor(range, "bla-bla", false, fixes, ProblemHighlightType.WEAK_WARNING); WriteCommandAction.runWriteCommandAction(getProject(), () -> { fix.applyFix(myFixture.getProject(), descriptor); }); myFixture.checkResultByFile(getTestName(false) + "_after.groovy"); }