void () { final Project project = myProjectFixture.getProject(); final PsiClass psiClass = findTestClass(project); final String className = psiClass.getName(); final TestNGConfiguration configuration = createConfiguration(project); final PsiMethod method = findTestMethod(psiClass); configuration.beMethodConfiguration(new PsiLocation<>(project, method)); final String newMethodName = "renamedTest"; final RenameRefactoring renameMethod = RefactoringFactory.getInstance(project).createRename(method, newMethodName); renameMethod.setSearchInComments(false); renameMethod.setSearchInNonJavaFiles(false); WriteCommandAction.runWriteCommandAction(project, () -> renameMethod.run()); Assert.assertEquals(className, configuration.getPersistantData().getMainClassName()); Assert.assertEquals(newMethodName, configuration.getPersistantData().getMethodName()); final PsiMethod notATestMethod = findNotATestMethod(psiClass); final RenameRefactoring renameNotATestMethod1 = RefactoringFactory.getInstance(project).createRename(notATestMethod, "bbbbb"); renameNotATestMethod1.setSearchInComments(false); renameNotATestMethod1.setSearchInNonJavaFiles(false); WriteCommandAction.runWriteCommandAction(project, () -> renameNotATestMethod1.run()); Assert.assertEquals(className, configuration.getPersistantData().getMainClassName()); Assert.assertEquals(newMethodName, configuration.getPersistantData().getMethodName()); }