void () { String methodText = "public void tearDown() {\n //comment\n }"; PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject()); PsiMethod method = factory.createMethodFromText(methodText, null); GenerateMembersUtil.setupGeneratedMethod(method); assertEquals(methodText, method.getText()); //empty template PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject()) .createFileFromText(JavaLanguage.INSTANCE, "class A {void foo() {}}\n class B extends A {void foo() {}\n}"); ApplicationManager.getApplication().runWriteAction(() -> { PsiMethod newMethod = file.getClasses()[1].getMethods()[0]; GenerateMembersUtil.setupGeneratedMethod(newMethod); assertEquals(""" @Override void foo() { super.foo(); }""", newMethod.getText()); }); }