I want to write a test for my intellij idea plugin. It operates on java files and generates tests for them.
Now I'd like to create a unit test, that only tests the Unit Test generation part. My idea is to prepare some testdata Java classes and the let generate the unit tests for them and then check if they are correctly generated.
The problem I have is, that I haven't found a possibility yet how to load a java file (or a text file) into an instance of PsiClass. It can be done by a code similar to the following one, if your code is run within the Itellij Idea gui code and if the file is in the open project, which is not my case for the test.
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File("path\\SimpleClass.java"));
var projects = ProjectManager.getInstance().getOpenProjects();
PsiFile file = PsiManager.getInstance(projects[0]).findFile(vf);
Any code samples or ideas how to achieve this? Or maybe another aproach how to get an instance of PsiClass as a test input?
Thanx in advance.