void () { XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("dummy.xml", XmlFileType.INSTANCE, "<fooBarGoo attr>1</fooBarGoo>", 0, true); final XmlTag tag = file.getDocument().getRootTag(); final Document document = file.getViewProvider().getDocument(); ApplicationManager.getApplication().runWriteAction(() -> { tag.setAttribute("attr", ""); assertEquals("<fooBarGoo attr=\"\">1</fooBarGoo>", tag.getText()); assertEquals("<fooBarGoo attr=\"\">1</fooBarGoo>", document.getText()); }); }