Template (@NotNull String name, @NotNull String group, @NotNull String text, Class<? extends TemplateContextType> ...contextsToDisable) { final TemplateManager templateManager = TemplateManager.getInstance(getProject()); final Template template = templateManager.createTemplate(name, group, text); TemplateContextType context = TemplateContextTypes.getByClass(JsonContextType.class); assertNotNull(context); ((TemplateImpl)template).getTemplateContext().setEnabled(context, true); for (Class<? extends TemplateContextType> ctx: contextsToDisable) { context = TemplateContextTypes.getByClass(ctx); assertNotNull(context); ((TemplateImpl)template).getTemplateContext().setEnabled(context, false); } CodeInsightTestUtil.addTemplate(template, myFixture.getTestRootDisposable()); return template; }