I am trying to run JUnits from my IntelliJ Idea When I try to run the Test.java file it gives me an error saying that
java: OutOfMemoryError: insuffic
Idea runs unit tests in a separate java process.
You need to use
Run -> Edit Configurations...
and add your -XmxNNNm
to VM Options.
For example:
-ea -Xmx1024m
The "-ea" means "enable assertions".
If your unit test(s) can't run in a 1GB of memory then it's possible that you have a memory leak.
As this OOM
happened during compilation, you need to increase compile VM:
In my case, my SpringBootTest configuration has Build (whole project) gradle task in "Before launch". So that's my omission. Eliminating that and issue's gone away.
Or Settings -> Compiler : increase build heap size
To increase heap size is one option. For me (using subversion for source version control) it was even easier to unload some of the modules which I had checked out and where not directly used for the test. This will also speed up the build process for future tests.
Right click on any module in the project-area of IntelliJ -> Load/Unload modudules -> Choose one/some bigger module and move to the "unload" area.
Based on your log the problem is in compiler heap space.
Go to
Settings -> Compiler -> Build process heap size (MB)
and increase that value.