JetBrains-Research / TestSpark

TestSpark - a plugin for generating unit tests. TestSpark natively integrates different AI-based test generation tools and techniques in the IDE. Started by SERG TU Delft. Currently under implementation by JetBrains Research (ICTL) for research purposes.
MIT License
35 stars 9 forks source link

New project importer for headless mode #262

Closed AbdullinAM closed 2 weeks ago

AbdullinAM commented 2 weeks ago

Description of changes made

  1. New project importer for headless mode that fixes the main issues with unresolved projects.
  2. Some headless mode fixes from pderakhshanfar/bug-fix/nullsdk, mainly an option to use default JDK if the IJ was not able to resolve the project JDK
  3. An option to turn off the coverage computation in the headless mode, mainly because of sometimes IJ cannot resolve project modules and fails with null pointer on
    ProjectFileIndex.getInstance(project).getModuleForFile(targetPsiClass.containingFile.virtualFile)

Why is merge request needed

Fix headless mode

Other notes

With the new project import, our previous issues with test generation seem to be resolved. There are still some issues with the project resolve:

However, I have implemented workarounds for those issues that seem to be working.

What is missing?

Please mention if anything is missing for this merge request, e.g you have decided to move something to the next merge request

Vladislav0Art commented 2 weeks ago

I have started the pipeline to check for correctness.

I had the following exception (see log file). It did not stop the generation, but I've never seen it before: testspark.log

Also, in the TestSparkStarter the classPath is created using ToolUtils.sep; for some reason, it breaks the compilation on the VM (this ToolUtils.sep renders either as an empty string or a slash (I did not figure which one exactly but not a colon :), therefore I manually need to replace it with ::

Screenshot 2024-06-19 at 17 47 47

Perhaps ToolUtils.sep is defined incorrectly.

AbdullinAM commented 2 weeks ago

@Vladislav0Art thank you for noticing that.

  1. Yes, this exception occurs for me as well. As far as I understand, it is an exception thrown by some of the IJ modules during project resolve. It does not affect the test generation for me too.
  2. Yes, that was an error in TestSparkStarter/ToolUtils, as ToolUtils.sep is defined as File.separatorChar, while we need File.pathSeparatorChar. I have added new property in ToolUtils and used in in starter class.