void () { WriteCommandAction.writeCommandAction(getProject()).run(() -> { final XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("test.xhtml", "<a/>"); final XmlTag tagB = file.getDocument().getRootTag(); tagB.setAttribute("a", ""); assertEquals("<a a=\"\"/>", tagB.getText()); tagB.setAttribute("b", ""); assertEquals("<a a=\"\" b=\"\"/>", tagB.getText()); tagB.setAttribute("c", ""); assertEquals("<a a=\"\" b=\"\" c=\"\"/>", tagB.getText()); tagB.getAttributes()[1].delete(); assertEquals("<a a=\"\" c=\"\"/>", tagB.getText()); }); }