When I run a JUnit test case in Eclipse, it takes 20 seconds just to launch JUnit itself.
In the Progress view it is at 87% for most of this time, stating: Launching: Starting virtual machine...
I have tried increasing the memory allocation to the vm in both eclipse.ini, and also in the Run Configuration for the unit tests (VM arguments: -Xms512m -Xmx1024m), but neither makes a difference.
I'm watching Windows Task Manager when I launch the unit test and I see a new java process get created with only 140K memory, it jumps up to about 20,000K just as JUnit finally starts.
So if I could see the new java process starting with the amount of memory I configured, I could at least rule out JVM memory as the cause of the slow launch. But I'm kind of stuck. I saw a recommendation somewhere to use this, but it also did not work: -Djava.net.preferIPv4Stack=true
Here's my eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.php.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:/Program Files/Java/jdk1.7.0_79/bin/javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms512m
-Xmx1024m
-Djava.net.preferIPv4Stack=true
If you right click in Project Explorer and choose New, you see a much shorter menu that doesn't include the Junit option. Needs to be done in Package Explorer view...
To use JUnit you must create a separate . java file in your project that will test one of your existing classes. In the Package Explorer area on the left side of the Eclipse window, right-click the class you want to test and click New → JUnit Test Case. A dialog box will pop up to help you create your test case.
JUnit simplifies the Unit testing process in Java with visual indicators and a Unit testing framework. JUnit use in the Eclipse IDE is convenient and quick to configure.
I know it's a late answer. But that can help others.
Usually it's because the project is afflicted with one of those non-incremental project nature like maven (particularly with a non-incremental maven compile phase plugin) and/or WTP auto publishing, etc. In console view, you can show the maven console, this may reveal what it is doing. Anything related to a remote subclipse/subversion or git during a build would definitely cost some time too.
If you had build automatically, you should not need to build on junit start. Turn all building off on junit launch, but be sure to have the prj built of course (if not automatically then by 'build project' or 'build all').
Also, if you have a project with a ridiculously large number or dependencies jars and you are using a placeholder jar to make command line shorter, then it may be the production of this tmp jar which slows you down, but I doubt it would take 20s.
You may want to try "-noverify" in jvmargs if bypassing class byte code verification is acceptable to you, locally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With