void () { VirtualFile file = createChildData(myPrjDir1, "a.txt"); FileManager fileManager = myPsiManager.getFileManager(); PsiFile psiFile = fileManager.findFile(file);//it's important to hold the reference EventsTestListener listener = new EventsTestListener(); myPsiManager.addPsiTreeChangeListener(listener,getTestRootDisposable()); delete(file); String string = listener.getEventsString(); String expected = """ beforeChildRemoval childRemoved """; assertEquals(psiFile.getName(), expected, string); }