void () { myFixture.addClass(""" package mycompany; public class File { public static File createTempFile(String pr, String postfix){return createTempFile(pr, postfix, null);} public static File createTempFile(String pr, String postfix, String base){return new File();} }"""); @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java"; myFixture.configureByFile(fileName); PsiClass fileClass = myFixture.findClass("mycompany.File"); final PsiFile file = fileClass.getContainingFile(); WriteCommandAction.runWriteCommandAction(null, () -> { try { file.getVirtualFile().setWritable(false); } catch (IOException e) { throw new RuntimeException(e); } }); PsiMethod element = null; PsiMethod[] createTempFiles = fileClass.findMethodsByName("createTempFile", false); for (PsiMethod createTempFile : createTempFiles) { if (createTempFile.getParameterList().getParametersCount() == 2) { element = createTempFile; break; } } assertNotNull(element); PsiMethod method = element; final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method); assertFalse("Bad returns found", condition); final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, getEditor(), false); processor.run(); myFixture.checkResultByFile(fileName + ".after"); }