void (String key, String text, String description, String group) { TemplateManager manager = TemplateManager.getInstance(getProject()); TemplateImpl template = (TemplateImpl)manager.createTemplate(key, group, text); template.setDescription(description); TemplateContextType contextType = TemplateContextTypes.getByClass(JavaCodeContextType.Generic.class); template.getTemplateContext().setEnabled(contextType, true); CodeInsightTestUtil.addTemplate(template, myFixture.getTestRootDisposable()); }